Submission #898039

#TimeUsernameProblemLanguageResultExecution timeMemory
898039andrei_iorgulescuArt Exhibition (JOI18_art)C++14
100 / 100
141 ms24920 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n; pair<int,int> a[500005]; int sp[500005]; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second; sort(a + 1,a + n + 1); for (int i = 1; i <= n; i++) sp[i] = sp[i - 1] + a[i].second; int ans = 0,mx = 0; for (int i = 1; i <= n; i++) { ///basically asta are size maxim, vreau sa maximizez sp[i] - sp[j - 1] + size[j] -> caut cea cu size[j] - sp[j - 1] maxima mx = max(mx,a[i].first - sp[i - 1]); ans = max(ans,sp[i] + mx - a[i].first); } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...