이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimzize("Ofast,no-stack-protector")
#include<bits/stdc++.h>
#define int long long
#define quick ios::sync_with_stdio(0);cin.tie(0);
#define rep(x,a,b) for(int x=a;x<=b;x++)
#define repd(x,a,b) for(int x=a;x>=b;x--)
#define lowbit(x) (x&-x)
#define sz(x) (int)(x.size())
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define mp make_pair
#define eb emplace_back
using namespace std;
typedef complex<int> P;
#define X real()
#define Y imag()
typedef pair<int,int> pii;
void debug(){
cout<<"\n";
}
template <class T,class ... U >
void debug(T a, U ... b){
cout<<a<<" ",debug(b...);
}
const int N=5e5+7;
const int INF=1e18;
pii p[N];
int a[N];
int pb[N];
int mx[N];
signed main(){
quick
int n;
cin>>n;
rep(i,1,n){
cin>>p[i].F>>p[i].S;
}
sort(p+1,p+n+1);
rep(i,1,n) a[i]=p[i].F,pb[i]=pb[i-1]+p[i].S;
mx[n+1]=-INF;
repd(i,n,1){
mx[i]=max(mx[i+1],pb[i]-a[i]);
}
int ans=0;
rep(i,1,n){
ans=max(ans,mx[i]+a[i]-pb[i-1]);
}
cout<<ans<<"\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
art.cpp:1: warning: ignoring '#pragma GCC optimzize' [-Wunknown-pragmas]
1 | #pragma GCC optimzize("Ofast,no-stack-protector")
|
# | 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... |