Submission #550537

#TimeUsernameProblemLanguageResultExecution timeMemory
550537KiprasArt Exhibition (JOI18_art)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; const ll maxN = 5e5+10; vector<pair<ll, ll>> a; map<ll, ll> b; ll n; int main() { ios_base::sync_with_stdio(0);cin.tie(nullptr); cin>>n; for(int i = 0; i < n; i++){ ll aa, bb; cin>>aa>>bb; a.push_back({aa, bb}); } for(int i = 0; i < n; i++){ b[a[i].first]+=a[i].second; } a.clear(); for(auto i : b){ a.push_back({i.first, i.second}); } sort(a.begin(), a.end()); n = a.size(); ll i = 0, j = 0; ll s=a[0].second; ll mx=0; while(j<n-1){ //cout<<s<<" "<<i<<" "<<j<<" "<<abs(a[j].first-a[i].first)<<endl; mx=max(mx, s-abs(a[j].first-a[i].first)); if(i!=j&&a[i+1].first-a[i].first>=a[i].second){ s-=a[i].second; i++; continue; } j++; s+=a[j].second; } while(i<n){ mx=max(mx, s-abs(a[j].first-a[i].first));{ s-=a[i].second; i++; } mx=max(mx, s-abs(a[j].first-a[i].first)); cout<<mx; return 0; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:67:1: error: expected '}' at end of input
   67 | }
      | ^
art.cpp:14:1: note: to match this '{'
   14 | {
      | ^