# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1158738 | pinbu | Art Exhibition (JOI18_art) | C++20 | 534 ms | 31748 KiB |
#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
const long long oo = 1e18;
int n;
map<long long, long long> v;
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; i++) {
long long a, b; cin >> a >> b;
v[a] += b;
}
long long prf = 0, mx = -oo, ans = -oo;
for (auto x: v) {
mx = max(mx, -prf + x.first);
prf += x.second;
ans = max(ans, prf + mx - x.first);
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |