Submission #1049741

# Submission time Handle Problem Language Result Execution time Memory
1049741 2024-08-09T04:36:38 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
0 ms 348 KB
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<set>
using namespace std;

#define ll long long

const ll maxn=500001;

ll n,ans=0;
pair<ll,ll> art[maxn];
      
int main(){
      cin>>n;
      for(int i=0;i<n;i++){
            cin>>art[i].first>>art[i].second;
      }
      sort(art,art+n);
      ll l=0,r=1,curans=0,prevans=0,su=art[0].second;
      while(l<n){
            curans=su-(art[r-1].first-art[l].first);
            if(curans>=prevans and r<n){
                  r++;
                  su+=art[r-1].second;
                  prevans=curans;
            }else{
                  su-=art[l].second;
                  l++;
                  prevans=0;
            }
            r=max(r,l);
            ans=max(ans,curans);
      }
      cout<<ans<<endl;
      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 -