제출 #335370

#제출 시각아이디문제언어결과실행 시간메모리
335370AQTArt Exhibition (JOI18_art)C++14
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> using namespace std; int N; pair<long long, long long> arr[500005]; long long pre[500005]; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N; for(int i = 1; i<=N; i++){ cin >> arr[i].first >> arr[i].second; } sort(arr+1, arr+1+N); for(int i = 1; i<=N; i++){ pre[i] = pre[i-1] + arr[i].second; } long long mn = LLONG_MAX/4; long long ans = 0; for(int i = 1; i<=N; i++){ ans = max(ans, pre[i] - arr[i].first - mn); mn = min(mn, - arr[i].first + pre[i-1]); } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...