Submission #787631

#TimeUsernameProblemLanguageResultExecution timeMemory
787631That_SalamanderArt Exhibition (JOI18_art)C++14
50 / 100
1062 ms24576 KiB
#include <bits/stdc++.h> #define int long long #define FOR(var,bound) for(int var = 0; var < bound; var++) #define FORB(var,lb,ub) for (int var = lb; var < ub; var++) #define FORR(var,bound) for(int var = bound-1; var >= 0; var--) using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef pair<int, int> pii; int n; pii art[500000]; int prefixValue[500005]; int getValue(int l, int r) { int s = prefixValue[r+1] - prefixValue[l]; return s - (art[r].first - art[l].first); } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; FOR(i, n) { cin >> art[i].first >> art[i].second; } sort(art, art + n); prefixValue[0] = 0; FOR(i, n) { prefixValue[i+1] = prefixValue[i] + art[i].second; } int res = 0; FOR(i, n) { FORB(j, i, n) { res = max(res, getValue(i, j)); } } cout << res << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...