Submission #1193402

#TimeUsernameProblemLanguageResultExecution timeMemory
1193402SnowRaven52Hacker (BOI15_hac)C++20
Compilation error
0 ms0 KiB
int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a(2 * n + 1); a[0] = 0; multiset<int> vals; int wsz = (n + 1) / 2; for (int i = 1; i <= n; ++i) { cin >> a[i]; a[n + i] = a[i]; } for (int i = 1; i <= 2 * n; ++i) { a[i] += a[i - 1]; } int answer = 0; vector<int> minSums(n + 1, INT_MAX); for (int i = 1; i <= 2 * n; ++i) { if (i + wsz - 1 <= 2 * n) { int sum = a[i + wsz - 1] - a[i - 1]; vals.insert(sum); } if (i > wsz) { int oldSum = a[i - 1] - a[i - 1 - wsz]; vals.erase(vals.find(oldSum)); } int position = ((i - 1) % n) + 1; if (!vals.empty()) { minSums[position] = min(minSums[position], *vals.begin()); } } for (int i = 1; i <= n; ++i) { answer = max(answer, minSums[i]); } cout << answer << endl; }

Compilation message (stderr)

hac.cpp: In function 'int main()':
hac.cpp:2:5: error: 'ios' has not been declared
    2 |     ios::sync_with_stdio(false);
      |     ^~~
hac.cpp:3:5: error: 'cin' was not declared in this scope
    3 |     cin.tie(0);
      |     ^~~
hac.cpp:7:5: error: 'vector' was not declared in this scope
    7 |     vector<int> a(2 * n + 1);
      |     ^~~~~~
hac.cpp:7:12: error: expected primary-expression before 'int'
    7 |     vector<int> a(2 * n + 1);
      |            ^~~
hac.cpp:8:5: error: 'a' was not declared in this scope
    8 |     a[0] = 0;
      |     ^
hac.cpp:10:5: error: 'multiset' was not declared in this scope
   10 |     multiset<int> vals;
      |     ^~~~~~~~
hac.cpp:10:14: error: expected primary-expression before 'int'
   10 |     multiset<int> vals;
      |              ^~~
hac.cpp:23:12: error: expected primary-expression before 'int'
   23 |     vector<int> minSums(n + 1, INT_MAX);
      |            ^~~
hac.cpp:28:13: error: 'vals' was not declared in this scope
   28 |             vals.insert(sum);
      |             ^~~~
hac.cpp:32:13: error: 'vals' was not declared in this scope
   32 |             vals.erase(vals.find(oldSum));
      |             ^~~~
hac.cpp:35:14: error: 'vals' was not declared in this scope
   35 |         if (!vals.empty()) {
      |              ^~~~
hac.cpp:36:13: error: 'minSums' was not declared in this scope
   36 |             minSums[position] = min(minSums[position], *vals.begin());
      |             ^~~~~~~
hac.cpp:36:33: error: 'min' was not declared in this scope; did you mean 'main'?
   36 |             minSums[position] = min(minSums[position], *vals.begin());
      |                                 ^~~
      |                                 main
hac.cpp:41:30: error: 'minSums' was not declared in this scope
   41 |         answer = max(answer, minSums[i]);
      |                              ^~~~~~~
hac.cpp:41:18: error: 'max' was not declared in this scope
   41 |         answer = max(answer, minSums[i]);
      |                  ^~~
hac.cpp:44:5: error: 'cout' was not declared in this scope
   44 |     cout << answer << endl;
      |     ^~~~
hac.cpp:44:23: error: 'endl' was not declared in this scope
   44 |     cout << answer << endl;
      |                       ^~~~