이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2,fma")
#include"bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define endl '\n'
#define mod 1000000007
//\
#define mod 1686876991
signed main () {
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
pair<int,int> a[n];
for (auto &[x, y] : a) cin >> x >> y;
sort(a, a + n);
multiset<int> s = {0};
int sm = 0;
for (int i = n - 1 ; i > 0 ; i--) {
sm += a[i].second + a[i - 1].first - a[i].first;
s.insert(sm);
}
sm += a[0].second;
int ans = 0;
for (int i = 0 ; i < n ; i++) ans = max(ans, a[i].second);
for (int i = 0 ; i < n - 1 ; i++) {
ans = max(ans, sm - *s.begin());
sm -= a[i].second;
s.erase(s.find(sm));
sm += a[i + 1].first;
sm -= a[i].first;
}
cout << ans << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
art.cpp:17:1: warning: multi-line comment [-Wcomment]
17 | //\
| ^
# | 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... |