Submission #131236

#TimeUsernameProblemLanguageResultExecution timeMemory
131236joylintpArt Exhibition (JOI18_art)C++17
0 / 100
2 ms380 KiB
#include<bits/stdc++.h> #define int long long using namespace std; pair<int, int> arr[500001]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) cin >> arr[i].first >> arr[i].second; sort(arr, arr + n + 1); for (int i = 1; i <= n; i++) arr[i].second += arr[i - 1].second; int ans = arr[1].second, now, i = 1; for (int j = 1; j <= n; j++) { now = arr[j].second - arr[i - 1].second - arr[j].first + arr[i].first; while (i < j && now <= arr[j].second - arr[i].second - arr[j].first + arr[i + 1].first) i++, now = arr[j].second - arr[i].second - arr[j].first + arr[i + 1].first; ans = max(ans, now); } 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...