Submission #430187

#TimeUsernameProblemLanguageResultExecution timeMemory
430187ApiramArt Exhibition (JOI18_art)C++14
100 / 100
237 ms20928 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin>>n; vector<pair<int64_t,int64_t>>arr(n); for (int i =0;i<n;++i){ cin>>arr[i].first>>arr[i].second; } sort(arr.begin(),arr.end(),[&](pair<int64_t,int64_t>a,pair<int64_t,int64_t>b){ return a.first<b.first; }); int64_t ans=0; int64_t cur =0; int64_t maxxy=0; for (int i =0;i<n;++i){ ans =max(cur+arr[i].second - arr[i].first,ans); ans=max(ans,arr[i].second); cur = max(cur + arr[i].second ,arr[i].second+arr[i].first); } cout<<ans<<endl; return 0;}

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:17:9: warning: unused variable 'maxxy' [-Wunused-variable]
   17 | int64_t maxxy=0;
      |         ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...