fork download
  1. const int OO = (int)(1e9 + 7);
  2. const int MAXN = (int)(1e3+5);
  3.  
  4. struct Cashier
  5. {
  6. long long m;
  7. long long s, p;
  8. };
  9.  
  10. Cashier a[MAXN];
  11. bool used[MAXN];
  12. int r, b, c;
  13.  
  14. bool check(long long t)
  15. {
  16. memset(used, false, sizeof(used));
  17. int num = b;
  18. for(int i = 1; i <= r; ++i)
  19. {
  20. if (num <= 0)
  21. break;
  22. int pos = 0;
  23. int maxItems = 0;
  24. for(int j = 1; j <= c; ++j)
  25. if (!used[j])
  26. {
  27. int items = min(a[j].m, (t - a[j].p) / a[j].s);
  28. if (items > maxItems)
  29. pos = j, maxItems = items;
  30. }
  31. num -= maxItems;
  32. used[pos] = true;
  33. }
  34. return num <= 0;
  35. }
  36.  
  37. void Inp()
  38. {
  39. int t;
  40. cin >> t;
  41. For(iTest, 1, t)
  42. {
  43. cout << "Case #" << iTest << ": ";
  44. cin >> r >> b >> c;
  45. for(int i = 1; i <= c; ++i)
  46. cin >> a[i].m >> a[i].s >> a[i].p;
  47. long long lo = 0, hi = 1LL * OO * OO + OO, mid = (lo + hi) / 2;
  48. while (lo != mid && hi != mid)
  49. {
  50. if (check(mid))
  51. hi = mid;
  52. else
  53. lo = mid;
  54. mid = (lo + hi) / 2;
  55. }
  56. for(long long i = lo; i <= hi; ++i)
  57. if (check(i))
  58. {
  59. cout << i;
  60. break;
  61. }
  62. cout << '\n';
  63. }
  64. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘bool check(long long int)’:
prog.cpp:16:37: error: ‘memset’ was not declared in this scope
     memset(used, false, sizeof(used));
                                     ^
prog.cpp:27:62: error: ‘min’ was not declared in this scope
                 int items = min(a[j].m, (t - a[j].p) / a[j].s);
                                                              ^
prog.cpp: In function ‘void Inp()’:
prog.cpp:40:5: error: ‘cin’ was not declared in this scope
     cin >> t;
     ^~~
prog.cpp:41:9: error: ‘iTest’ was not declared in this scope
     For(iTest, 1, t)
         ^~~~~
prog.cpp:41:20: error: ‘For’ was not declared in this scope
     For(iTest, 1, t)
                    ^
stdout
Standard output is empty