제출 #782526

#제출 시각아이디문제언어결과실행 시간메모리
782526acatmeowmeowArt Exhibition (JOI18_art)C++11
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<pair<int, int>> arr(n + 5); for (int i = 1; i <= n; i++) cin >> arr[i].first >> arr[i].second; sort(arr.begin() + 1, arr.begin() + n + 1); vector<int> prefix(n +5 ); for (int i = 1; i <= n; i++) prefix[i] = arr[i].second + prefix[i - 1]; int mn = -prefix[0] + arr[1].first; int ans = -1e18; for (int i = 1; i <= n; i++) { ans = max(ans, prefix[i] - arr[i].first + mn); mn = max(mn, -prefix[i] + arr[i].first); } 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...