제출 #1086258

#제출 시각아이디문제언어결과실행 시간메모리
1086258codexistentArt Exhibition (JOI18_art)C++14
0 / 100
0 ms344 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define MAXN 500005 #define FOR(i, a, b) for(ll i = a; i <= b; i++) ll n, pfx[MAXN], r = 0; pair<ll, ll> w[MAXN]; int main(){ cin >> n; FOR(i, 1, n) cin >> w[i].first >> w[i].second; sort(w + 1, w + 1 + n); pfx[0] = 0; FOR(i, 1, n) pfx[i] = pfx[i - 1] + w[i].second; ll mn = -w[1].first; FOR(i, 1, n){ r = max(r, (pfx[i] - w[i].first) - mn); mn = min(mn, pfx[i] - w[i].first); } cout << r << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...