This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <iostream>
#include<queue>
#include<vector>
#include<utility>
using namespace std;
typedef long long ll;
const int sz=101;
const int sz1=2e5+1;
int n,x,k,i,j,w,m;
ll res=1e18;
ll ans=0;
int movex[4]={0,0,1,-1};
int movey[4]={-1,1,0,0};
ll c[sz1];
vector<ll>adj[sz];
ll d[sz1];
vector<array<ll,2>>pic;
ll dp[sz][sz];
int main(){
cin>>n;
for(int i=0;i<n;i++){
ll u,v ;cin>>u>>v;
pic.push_back({u,v});
} sort(pic.begin(),pic.end());
for(int i=1;i<=n;i++){
d[i]=pic[i-1][1]+d[i-1];
}
ll curmax=0;ll curmin=pic[0][0]; ans=pic[0][1];
for(int i=1;i<=n;i++){
ans=max(ans,d[i]+curmin-pic[i-1][0]);
} cout<<ans;
}
Compilation message (stderr)
art.cpp: In function 'int main()':
art.cpp:29:8: warning: unused variable 'curmax' [-Wunused-variable]
29 | ll curmax=0;ll curmin=pic[0][0]; ans=pic[0][1];
| ^~~~~~
# | 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... |