Submission #1229121

#TimeUsernameProblemLanguageResultExecution timeMemory
1229121liamczarArt Exhibition (JOI18_art)C++20
0 / 100
0 ms328 KiB
#include<bits/stdc++.h> using namespace std; int main (){ ios::sync_with_stdio(false); cin.tie(nullptr); long long n; cin >> n; vector<pair<long long,long long>> a(n); for(int i=0; i<n; i++) cin >> a[i].first >> a[i].second; sort(a.begin(), a.end()); long long res=0, l=0, tong=0; for(int r=0; r<n; r++){ tong+=a[r].second; while (l < r) { long long sum = tong - a[l].second; long long amin = a[l + 1].first; long long amax = a[r].first; if (sum - (amax - amin) >= tong - (amax - a[l].first)) { tong = sum; l++; } else break; } long long amin = a[l].first; long long amax = a[r].first; res = max(res, tong - (amax - amin)); } cout << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...