fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4.  
  5. int main() {
  6. int t, u, n, m, c, no;
  7. double r, d, a, b;
  8. scanf("%d", &t);
  9. while(t--) {
  10. scanf("%lf%d%d", &d, &u, &n);
  11. no=0;
  12. b=d*u;
  13. for(int i=0; i<n; i++) {
  14. scanf("%d%lf%d", &m, &r, &c);
  15. a=u*r+c/(double)m;
  16. if(a<b) { b=a; no=i+1; }
  17. }
  18. printf("%d\n", no);
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0s 3300KB
stdin
4
1.00 200 1
1 0.50 28
1.00 200 2
1 0.75 40
3 0.60 100
1.00 50 2
1 0.75 40
3 0.60 100
1.00 100 2
3 0.50 10
2 0.10 20
stdout
1
2
0
2