Submission #926613

#TimeUsernameProblemLanguageResultExecution timeMemory
926613VMaksimoski008Art Exhibition (JOI18_art)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n; cin >> n; vector<pair<ll, ll> > v(n+1); for(int i=1; i<=n; i++) cin >> v[i].first >> v[i].second; sort(v.begin()+1, v.end()); ll ans = 0, mx = -1e18, S = 0; for(int i=1; i<=n; i++) { mx = max(mx, v[i].first - S); S += v[i].second ans = max(ans, S - v[i].first + mx); } cout << ans << '\n'; return 0; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:16:25: error: expected ';' before 'ans'
   16 |         S += v[i].second
      |                         ^
      |                         ;
   17 |         ans = max(ans, S - v[i].first + mx);
      |         ~~~