fork download
  1. class Mutalisk {
  2. public:
  3. int can[55];
  4. int hp[55];
  5. #undef int
  6. int minimalAttacks(vector <int> x) {
  7. #define int long long
  8. int n = SZ(x);
  9. set<PII> all;
  10. REP (i, n) {
  11. all.insert({x[i], i + 1});
  12. }
  13.  
  14. int kl1 = 0, kp1 = 200, faj1 = -1;
  15.  
  16. while (kl1 <= kp1) {
  17.  
  18. int aktc1 = (kl1 + kp1) / 2;
  19. debug(aktc1);
  20. auto cur = all;
  21. VI vals{9, 3, 1};
  22. RE (i, n) {
  23. can[i] = aktc1;
  24. }
  25. RE (i, n) {
  26. hp[i] = x[i - 1];
  27. }
  28. int fail = 0;
  29. for (auto v : vals) {
  30. int rem = aktc1;
  31. if (v > 1) {
  32. int nxt = v / 3;
  33. RE (i, n) {
  34. if (can[i] * v < hp[i]) {
  35. fail = 1;
  36. break;
  37. }
  38. int kl2 = 0, kp2 = can[i], faj2 = 0;
  39. while (kl2 <= kp2) {
  40. int aktc2 = (kl2 + kp2) / 2;
  41. if (hp[i] <= (can[i] - aktc2) * nxt + aktc2 * v) {
  42. faj2 = aktc2;
  43. kp2 = aktc2 - 1;
  44. } else {
  45. kl2 = aktc2 + 1;
  46. }
  47. }
  48. rem -= faj2;
  49. cur.erase(MP(hp[i], i));
  50. can[i] -= faj2;
  51. hp[i] -= v * faj2;
  52. if (hp[i] > 0) {
  53. cur.insert(MP(hp[i], i));
  54. }
  55. }
  56. }
  57. if (rem < 0) {
  58. fail = 1;
  59. break;
  60. }
  61. while (rem && SZ(cur)) {
  62. rem--;
  63. auto it = cur.end();
  64. it--;
  65. int wh = it->nd;
  66. cur.erase(it);
  67. can[wh]--;
  68. if (can[wh] < 0) {
  69. fail = 1;
  70. break;
  71. }
  72. hp[wh] -= v;
  73. if (hp[wh] > 0) {
  74. cur.insert({hp[wh], wh});
  75. }
  76. }
  77. }
  78. RE (i, n) {
  79. if (hp[i] > 0) {
  80. fail = 1;
  81. }
  82. cerr<<hp[i]<<" ";
  83.  
  84. }
  85. if (!fail) {
  86. faj1 = aktc1;
  87. kp1 = aktc1 - 1;
  88. } else {
  89. kl1 = aktc1 + 1;
  90. }
  91. }
  92. return faj1;
  93.  
  94. }
  95.  
  96. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:1: error: unknown type name 'class'
 class Mutalisk {
 ^
prog.c:1:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 class Mutalisk {
                ^
stdout
Standard output is empty