제출 #141516

#제출 시각아이디문제언어결과실행 시간메모리
141516osaaateiasavtnlArt Exhibition (JOI18_art)C++14
100 / 100
289 ms21012 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ii pair <int, int> #define app push_back #define all(a) a.begin(), a.end() const int N = 5e5 + 7, INF = 1e18 + 7; ii a[N]; signed main() { #ifdef HOME freopen("input.txt", "r", stdin); #else ios_base::sync_with_stdio(0); cin.tie(0); #endif int n; cin >> n; for (int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second; sort(a, a + n); int cur = -INF, p = 0, ans = -INF; for (int i = 0; i < n; ++i) { cur = max(cur, a[i].first - p); p += a[i].second; ans = max(ans, p - a[i].first + cur); } 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...