이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define F first
#define S second
#define pb push_back
const ll INF=2e18;
int main()
{
int n;
cin>>n;
vector<pll> p(n+1,{0,0});
rep1(i,n) cin>>p[i].F>>p[i].S;
sort(p.begin(),p.end());
ll cur=0,tmp=0,mn=INF,ans=0;
rep1(i,n)
{
cur+=p[i].S;
tmp+=p[i-1].S;
mn=min(mn,tmp-p[i].F);
ans=max(ans,cur-p[i].F-mn);
}
cout<<ans;
}
| # | 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... |