-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCodysJams.cpp
34 lines (29 loc) · 918 Bytes
/
CodysJams.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <cstdio>
#include <map>
#include <vector>
int main(){
int t; scanf("%d\n", &t);
for(int c = 1; c <= t; c++){
long n; scanf("%ld\n", &n);
std::map<long, long> prices;
for(long p = 0; p < 2 * n; p++){
long x; scanf("%ld", &x);
if(prices.count(x) == 0){prices[x] = 0;}
++prices[x];
}
std::vector<long> res;
while(prices.size() > 0){
long discPrice = prices.begin() -> first;
long rep = prices.begin() -> second;
prices.erase(discPrice);
if(rep <= 0){continue;}
for(long k = 0; k < rep; k++){res.push_back(discPrice);}
long regPrice = 4 * discPrice / 3;
prices[regPrice] -= rep;
}
printf("Case #%d: ", c);
for(long p = 0; p < res.size(); p++){printf("%ld ", res[p]);}
puts("");
}
return 0;
}