codechef HELLO - "hello hello" solution: http://ideone.com/RnU22b
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
int t, u, n, m, c, no;
double r, d, a, b;
scanf("%d", &t);
while(t--) {
scanf("%lf%d%d", &d, &u, &n);
no=0;
b=d*u;
for(int i=0; i<n; i++) {
scanf("%d%lf%d", &m, &r, &c);
a=u*r+c/(double)m;
if(a<b) { b=a; no=i+1; }
}
printf("%d\n", no);
}
return 0;
}
note: the minimum plan(a) that is lesser than actual monthly plan(b) would be helpful for chef, which is a<b, and print out that index(no)
No comments:
Post a Comment