-
Notifications
You must be signed in to change notification settings - Fork 11
/
vjudge_UVA-12157_tariff_plan.cpp
58 lines (46 loc) · 1.35 KB
/
vjudge_UVA-12157_tariff_plan.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// UVa 12157 Tariff Plan - Accepted
// Compare 2 plans to see what is the cheapest. Time O(total_tc * n), Mem O(1)
#include <bits/stdc++.h>
using namespace std;
int miles(int n){
int ans = (n/30 + 1)*10;
//cout << "mile("<< n << ") = " << ans << endl;
return ans;
}
int juice(int n){
int ans = (n/60 + 1)*15;
// cout << "juice("<< n << ") = " << ans << endl;
return ans;
}
int total_tc, n, k;
int main(){
cin >> total_tc;
for(int t=0; t<total_tc; t++){
cin >> n;
int total_miles, total_juice;
total_miles = total_juice = 0;
for (int i=0;i <n;i++){
cin >> k;
total_miles += miles(k);
total_juice += juice(k);
}
// cout << "total_miles " << total_miles << endl;
// cout << "total_juice " << total_juice << endl;
string best_plan;
int min_cost = 0;
if (total_miles < total_juice){
best_plan = "Mile";
min_cost = total_miles;
}
if (total_miles > total_juice){
best_plan = "Juice";
min_cost = total_juice;
}
if (total_miles == total_juice){
best_plan = "Mile Juice";
min_cost = total_miles;
}
cout << "Case " << t+1 << ": " << best_plan << " " << min_cost << endl;
}
return 0;
}