이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define maxn 50009
using namespace std;
pair<long long,long long> a[maxn];
long long A[maxn], s[maxn], B[maxn];
main(){
long long n;
cin >> n;
for(long long i= 1; i <= n; i++)
cin >> a[i].first >> a[i].second;
sort(a + 1, a + n + 1);
for(long long i = 1; i <= n; i++){
s[i] = s[i - 1] + a[i] . second;
}
for(long long i = 1 ; i <= n; i++){
A[i] = s[i] - a[i] . first;
B[i] = -a[i] .first + s[i - 1];
}
long long MI = 1e18, ans = -1e18;
for(long long i = 1; i <= n; i++){
MI = min(MI, B[i]);
ans = max(ans, A[i] - MI);
}
cout<< ans << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
art.cpp:6:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^| # | 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... |