Submission #392856

#TimeUsernameProblemLanguageResultExecution timeMemory
392856warner1129Art Exhibition (JOI18_art)C++17
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> #define ff first #define ss second using namespace std; const long long INF = 0xf3f3f3f3f3f3f3f; const int maxn = 5e5 + 5; pair<int, long long> arr[maxn]; void solve() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> arr[i].ff >> arr[i].ss; sort(arr + 1, arr + 1 + n); for (int i = 2; i <= n; i++) arr[i].ss += arr[i-1].ss; long long mi = -arr[1].ff; long long ans = -INF; for (int i = 1; i <= n; i++) { ans = max(ans, arr[i].ss - arr[i].ff - mi); mi = min(mi, arr[i].ss - arr[i+1].ff); } cout << ans << '\n'; } signed main() { solve(); 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...