Submission #960962

# Submission time Handle Problem Language Result Execution time Memory
960962 2024-04-11T09:57:43 Z batsukh2006 Art Exhibition (JOI18_art) C++17
0 / 100
0 ms 348 KB
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<map>
#include<string>
#include<algorithm>
#include<vector>
#include<string.h>
#include<utility>
#include<set>
#include<cmath>
#include<queue>
#include<deque>
#include<functional>
#include<stack>
#include<limits.h>
#include<iomanip>
#include<unordered_map> 
#include<numeric>
#include<tuple>
#include<bitset>
using namespace std;
 
#define MOD 1000000007
#define int long long
#define ss second
#define ff first
#define endl '\n'
typedef pair<int,int> pp;
signed main(){
    // freopen("file.in", "r", stdin);
    // freopen("file.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n; cin>>n;
    vector<pair<int,int> > v(n+1);
    for(int i=1; i<=n; i++){
    	int a,b; cin>>a>>b;
    	v[i]={a,b};
    }
    vector<int> pref(n+1);
    sort(v.begin(),v.end());
    for(int i=1; i<=n; i++){
    	pref[i]=pref[i-1]+v[i].ss;
    }
    int ans=0,f=0,s=1e18;
    for(int i=1; i<=n; i++){
    	f=max(f,pref[i]-v[i].ff);
    	if(i==1) ans=v[i].ss;
    	else ans=max(ans,f-s);
    	s=min(s,pref[i-1]-v[i].ff);
    }
    cout<<ans;
    return 0;
}



























# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -