Submission #897559

#TimeUsernameProblemLanguageResultExecution timeMemory
897559hennesseyArt Exhibition (JOI18_art)C++17
50 / 100
1060 ms20968 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { //your code goes here int n; cin >> n; vector <pair <int, int>> arr = {}; for(int i = 0; i < n; i++) { int s, v; cin >> s >> v; arr.push_back({s, v}); } sort(arr.begin(), arr.end(), [&](auto left, auto right) { return left.first < right.first; }); int maxj = 0; for(int i = 0; i < n; i++) { int val = 0; for(int j = i; j < n; j++) { val += arr[j].second; int val2 = arr[j].first-arr[i].first; maxj = max(maxj, val-val2); } } cout << maxj << endl; 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...