Submission #1115347

#TimeUsernameProblemLanguageResultExecution timeMemory
1115347staszic_ojuzArt Exhibition (JOI18_art)C++17
0 / 100
1 ms336 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n; cin >> n; vector<pair<ll, int>> sv; for(int i = 0; i < n; ++i) { ll a, b; cin >> a >> b; sv.push_back({a, b}); } sort(sv.begin(), sv.end()); ll sp[n+1]; sp[0] = 0; sp[1] = sv[0].second; for(int i = 2; i <= n; ++i) sp[i] = sp[i-1] + sv[i-1].second - sv[i-1].first + sv[i-2].first; ll mi = sp[0]; ll odp = -1e18+7; for(int i = 1; i <= n; ++i) { odp = max(odp, sp[i] - mi); mi = min(mi, sp[i]); } cout << odp; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...