Submission #493916

#TimeUsernameProblemLanguageResultExecution timeMemory
493916ahmeterenArt Exhibition (JOI18_art)C++17
0 / 100
1 ms204 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long const int N = 1e5 + 5; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // #ifndef ONLINE_JUDGE // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); // #endif ll n, cevap = 0, r = 1, sum = 0; cin >> n; vector<pair<ll, ll>> vec(n); for(int i = 0; i < n; i++) cin >> vec[i].first >> vec[i].second; sort(vec.begin(), vec.end()); sum = vec[0].second; for(int l = 0; l < n; l++) { if(r < l) { r = l; } while(r < n and sum + vec[r].second > vec[r].first - vec[l].first) { sum += vec[r].second; cevap = max(cevap, sum - (vec[r].first - vec[l].first)); r++; } sum -= vec[l].second; } cout << cevap << '\n'; 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...