Submission #1234565

#TimeUsernameProblemLanguageResultExecution timeMemory
1234565rhm_ganArt Exhibition (JOI18_art)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define dbg(...) 42 #endif int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<pair<int64_t, int64_t>> a(n); for (int i = 0; i < n; i++) { cin >> a[i].first >> a[i].second; } sort(a.begin(), a.end()); int64_t sum = 0, ans = 0; for (int l = 0, r = 0; r < n; r++) { sum = sum + a[r].second; ans = max(ans, sum - (a[r].first - a[l].first)); while (l + 1 <= r && sum - a[l].second - (a[r].first - a[l + 1].first) >= ans) { ans = sum - a[l].second - (a[r].first - a[l + 1].first); sum -= a[l].second; l++; } } cout << ans << '\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...