Submission #744350

#TimeUsernameProblemLanguageResultExecution timeMemory
744350MONArt Exhibition (JOI18_art)C++14
0 / 100
1 ms212 KiB
#include<iostream> #include<vector> #include<algorithm> using namespace std; using ll = long long; int main() { vector<pair<int,int>> arta; int n; ll a,b; cin >> n; for(int i = 1; i <= n ; i++) { cin >> a >> b; arta.push_back({a,b}); } sort(arta.begin(),arta.end()); ll suma = arta[0].second; ll minim = -arta[0].first,ans = -1e18,last = suma; for(int i = 1; i < n ; i++) { suma += arta[i].second; ans = max(ans,suma - arta[i].first - minim); minim = min(minim,last - arta[i].first); last = suma; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...