Submission #471286

#TimeUsernameProblemLanguageResultExecution timeMemory
471286IvnFArt Exhibition (JOI18_art)C++14
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ull unsigned long long #define fi first #define se second #define ld long double ll n, pref[500005]; pair<ll, ll>arr[500005]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(int i=1;i<=n;++i){ cin >> arr[i].fi >> arr[i].se; } sort(arr+1, arr+1+n); for(int i=1;i<=n;++i) pref[i]=pref[i-1]+arr[i].se; ll l=1, maks=0; for(int i=1;i<=n;++i){ while((pref[i]-pref[l-1])-(arr[i].fi-arr[l].fi) < 0){ ++l; } maks=max(maks, (pref[i]-pref[l-1])-(arr[i].fi-arr[l].fi)); } cout << maks << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...