Submission #678773

#TimeUsernameProblemLanguageResultExecution timeMemory
678773hello_there_123Art Exhibition (JOI18_art)C++17
100 / 100
529 ms33116 KiB
#include<bits/stdc++.h> using namespace std; #define int long long main(){ int n; cin>>n; vector<pair<int,int> >v2,v; int sum = 0; for(int i=0;i<n;i++){ int a,b; cin>>a>>b; v2.push_back(make_pair(a,b)); } sort(v2.begin(),v2.end()); v.push_back(make_pair(0,0)); for(int i=0;i<n;i++){ sum+=v2[i].second; v.push_back(make_pair(v2[i].first,sum)); } int ans =0; int maxi = -1e9; for(int i=1;i<=n;i++){ maxi = max(maxi,v[i].first-v[i-1].second); ans = max(ans,v[i].second-v[i].first+maxi); } cout<<ans; }

Compilation message (stderr)

art.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...