제출 #1285726

#제출 시각아이디문제언어결과실행 시간메모리
1285726nemkhoArt Exhibition (JOI18_art)C++17
0 / 100
0 ms332 KiB
#include <bits/stdc++.h> #define ll long long #define pr pair <ll, ll> #define fi first #define se second using namespace std; const int N = 5e5 + 5; ll pre[N], n, res; pr a[N]; void inp() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i].fi >> a[i].se; sort(a + 1, a + n + 1); } void solve() { for (int i = 1; i <= n; i++) pre[i] = pre[i-1] + a[i].se; ll _max = a[1].fi; for (int i = 1; i <= n; i++) { res = max(res, pre[i] - a[i].fi + _max); _max = max(_max, a[i].fi - pre[i-1]); } cout << res; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); inp(); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...