Submission #752114

#TimeUsernameProblemLanguageResultExecution timeMemory
752114vjudge1Art Exhibition (JOI18_art)C++17
0 / 100
0 ms212 KiB
#include<bits/stdc++.h> #define ll pair <long long,long long> using namespace std; ll a[1000002]; long long oo=100000000000000000; signed main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; for (int i=1;i<=n;i++) { cin >> a[i].first >> a[i].second; } sort (a+1,a+1+n); int i2=1; long long tong=0; long long kq=0-oo; for (int i=1;i<=n;i++) { tong=tong+a[i].second; while ((i2<i) and (a[i2+1].first-a[i2].first>a[i2].second)) { tong=tong-a[i2].second; i2++; } kq=max(kq,tong-(a[i].first-a[i2].first)); // cout << i << " " << i2 << " " << tong-(a[i].first-a[i2].first) << '\n'; } cout << kq; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...