Submission #577875

#TimeUsernameProblemLanguageResultExecution timeMemory
577875Trisanu_DasArt Exhibition (JOI18_art)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<pair<int, int>> a(n); for (auto p : v) cin >> p.first >> p.second; sort(a.begin(), a.end()); int pref[n + 1] for (int i = 0; i < n; i++) pref[i + 1] = pref[i] + v[i][1]; vector diff(pref + 1, pref + n + 1); for (int i = 0; i < n; i++) diff[i] -= v[i][0]; long ans = 0, tmp = INT_MIN / 2; for (int i = n - 1; i > -1; i--) { tmp = max(tmp, diff[i]); ans = max(ans, tmp + v[i][0] - pref[i]); } cout << ans << '\n'; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:7:19: error: 'v' was not declared in this scope
    7 |     for (auto p : v) cin >> p.first >> p.second;
      |                   ^
art.cpp:10:5: error: expected initializer before 'for'
   10 |     for (int i = 0; i < n; i++) pref[i + 1] = pref[i] + v[i][1];
      |     ^~~
art.cpp:10:21: error: 'i' was not declared in this scope
   10 |     for (int i = 0; i < n; i++) pref[i + 1] = pref[i] + v[i][1];
      |                     ^
art.cpp:11:17: error: 'pref' was not declared in this scope
   11 |     vector diff(pref + 1, pref + n + 1);
      |                 ^~~~
art.cpp:12:44: error: 'v' was not declared in this scope
   12 |     for (int i = 0; i < n; i++) diff[i] -= v[i][0];
      |                                            ^
art.cpp:16:55: error: 'v' was not declared in this scope
   16 |         tmp = max(tmp, diff[i]); ans = max(ans, tmp + v[i][0] - pref[i]);
      |                                                       ^