-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHELLO.cpp~
34 lines (33 loc) · 1.1 KB
/
HELLO.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<iostream>
using namespace std;
int main(){
int t;
cin >> t;
while(t!=0){
float initial_rate,mins,initial_cost;
int plans;
cin >> initial_rate >> mins >> plans;
initial_cost = initial_rate*mins;
float final_cost[plans/1];
int i=0,index;
float min_cost=initial_cost;
while(plans!=0){
float month,rate,act_cost;
cin >> month >> rate >> act_cost;
act_cost=act_cost/month;
final_cost[i]=rate*mins+act_cost;
if(final_cost[i] < min_cost){
min_cost=final_cost[i];
index=i;
}
i++;
plans--;
}
if(min_cost == initial_cost)
cout << 0 << endl;
else
cout << index+1 << endl;
t--;
}
return 0;
}