Submission #477714

#TimeUsernameProblemLanguageResultExecution timeMemory
477714Zhora_004쌀 창고 (IOI11_ricehub)C++17
Compilation error
0 ms0 KiB
int besthub(int n, int l, vector<int>& x, int tmp_b) { multiset<int> tmp; for (int i = 0; i < n; i++) tmp.insert(x[i]); int mx = 0; for (int i = 1; i <= l; i++) { int ans = 0; multiset<int> ms = tmp; int b = tmp_b; while (b) { auto it1 = ms.lower_bound(i); int num1 = -1, num2 = -1; if (it1 != ms.end()) num1 = *it1; if (it1 != ms.begin()) it1--, num2 = *it1; if (num1 == -1 && num2 == -1) continue; if (num1 == -1) { if (i - num2 <= b) b -= i - num2, ans++, ms.erase(ms.find(num2)); else break; } else if (num2 == -1) { if (num1 - i <= b) b -= num1 - i, ans++, ms.erase(ms.find(num1)); else break; } else { if (min(num1 - i, i - num2) <= b) { if (num1 - i <= i - num2) b -= num1 - i, ans++, ms.erase(ms.find(num1)); else b -= i - num2, ans++, ms.erase(ms.find(num2)); } else break; } } mx = max(mx, ans); } return mx; }

Compilation message (stderr)

ricehub.cpp:1:27: error: 'vector' has not been declared
    1 | int besthub(int n, int l, vector<int>& x, int tmp_b)
      |                           ^~~~~~
ricehub.cpp:1:33: error: expected ',' or '...' before '<' token
    1 | int besthub(int n, int l, vector<int>& x, int tmp_b)
      |                                 ^
ricehub.cpp: In function 'int besthub(int, int, int)':
ricehub.cpp:3:2: error: 'multiset' was not declared in this scope
    3 |  multiset<int> tmp;
      |  ^~~~~~~~
ricehub.cpp:3:11: error: expected primary-expression before 'int'
    3 |  multiset<int> tmp;
      |           ^~~
ricehub.cpp:4:30: error: 'tmp' was not declared in this scope
    4 |  for (int i = 0; i < n; i++) tmp.insert(x[i]);
      |                              ^~~
ricehub.cpp:4:41: error: 'x' was not declared in this scope
    4 |  for (int i = 0; i < n; i++) tmp.insert(x[i]);
      |                                         ^
ricehub.cpp:9:12: error: expected primary-expression before 'int'
    9 |   multiset<int> ms = tmp;
      |            ^~~
ricehub.cpp:10:11: error: 'tmp_b' was not declared in this scope
   10 |   int b = tmp_b;
      |           ^~~~~
ricehub.cpp:13:15: error: 'ms' was not declared in this scope; did you mean 'mx'?
   13 |    auto it1 = ms.lower_bound(i);
      |               ^~
      |               mx
ricehub.cpp:30:9: error: 'min' was not declared in this scope
   30 |     if (min(num1 - i, i - num2) <= b)
      |         ^~~
ricehub.cpp:38:8: error: 'max' was not declared in this scope; did you mean 'mx'?
   38 |   mx = max(mx, ans);
      |        ^~~
      |        mx