이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define rep(X, a,b) for(int X=a;X<b;++X)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (int)(a).size()
#define NL "\n"
using namespace std;
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;
typedef long long ll;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << "," << p.second << ')'; }
template<typename A> ostream& operator<<(ostream &os, const vector<A> &p){
for(const auto &a:p)
os << a << " ";
os << "\n";
return os;
}
typedef pair<ll, pll> ppp;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n;
cin>>n;
vector<pll> v(n);
rep(i,0,n) cin>>v[i].F>>v[i].S;
sort(ALL(v));
ll ans=0, tot=0, mx=0;
rep(i,0,n){
mx=max(mx, v[i].F-tot);
tot+=v[i].S;
ans=max(ans, tot-v[i].F+mx);
}
cout<<ans<<NL;
// ll n, m;
// cin>>n>>m;
// vector<string> grid(n);
// vector<vector<ll>> dp(n, vector<ll>(0,m));
// rep(i,0,n) cin>>grid[i];
// ll ans=0;
// rep(i,0,n){
// rep(j,0,m){
// if(grid[i][j]!='R') continue;
// //right
// if(m-j>=2){
// if(grid[i][j+1]=='G' && grid[i][j+2]=='W'){
// }
// }
// if(n-i>=2){
// ;
// }
// if(j-m>=2){
// ;
// }
// if(i-n>=2){
// ;
// }
// }
// }
}
# | 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... |