이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
using namespace std;
const ll N = 5e5+100;
const ll MOD = 1e9+7;
ll pre[N];
int main()
{
ll n;
cin>>n;
pll a[n+1];
for(int i =1;i<=n;i++)cin>>a[i].f >> a[i].s;
sort(a+1,a+n+1);
for(int i =1;i<=n;i++){
pre[i] = pre[i-1] + a[i].s;
}
ll ans = 0;
for(int i =1;i<=n;i++){
for(int j =i;j<=n;j++){
ans = max(ans,((pre[j]-pre[i-1]-(a[j].f-a[i].f))));
}
}
cout<<ans<<endl;
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... |