제출 #1302128

#제출 시각아이디문제언어결과실행 시간메모리
1302128duyanhchupapiArt Exhibition (JOI18_art)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 5e5 + 5, inf = 2e9; int n; pair <ll, ll> p[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); // freopen(".INP", "r", stdin); // freopen(".OUT", "w", stdout); cin >> n; for (int i=1;i<=n;++i) cin >> p[i].first >> p[i].second; sort(p + 1, p + n + 1); for (int i=1;i<=n;++i) p[i].second += p[i - 1].second;//, cout << p[i].first << ' ' << p[i].second << '\n'; ll MIN = -p[1].first, ans = -9e18; for (int i = 1; i <= n; ++i) { p[i].second -= p[i].first; ans = max(ans, p[i].second - MIN); MIN = min(MIN, p[i].second); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...