이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define maxn 500010
#define ll long long
map<ll, ll> mp;
int N;
ll a[maxn], b[maxn];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> N;
for (int i = 0; i < N; i++) {
cin >> a[i] >> b[i];
mp[0-a[i]] += b[i];
}
ll ans = 0LL;
ll cbest = 0;
ll lastval = 0-mp.begin()->first;
for (auto it = mp.begin(); it != mp.end(); ++it) {
ll cspot = 0-it->first;
ll cnum = it->second;
// cout << cspot << ": " << cnum << endl;
cbest = max(cnum, cbest - (lastval - cspot) + cnum);
ans = max(ans, cbest);
lastval = cspot;
}
cout << ans << endl;
}
| # | 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... |