이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
ll n;
cin>>n;
vector<pair<ll,ll>> v(n);
for(ll i=0;i<n;i++){
cin>>v[i].first>>v[i].second;
}
sort(v.begin(),v.end());
ll ans = 0;
for(ll i=0;i<n;i++){
ll tot = 0 , mi = 1e10, ma = 0;
for(ll j=i;j<n;j++){
tot += v[j].second;
mi = min(mi,v[j].first);
ma = max(ma,v[j].first);
ans = max(ans,tot - (ma - mi));
//cout<<i<<" "<<j<<" "<<tot<<" "<<ma<<" "<<mi<<" "<<ans<<endl;
}
}
cout<<ans<<endl;
}
int main()
{
solve();
return 0;
}
# | 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... |