Submission #914804

#TimeUsernameProblemLanguageResultExecution timeMemory
914804NurislamArt Exhibition (JOI18_art)C++14
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define int long long ///* __ __ __ */ ///* ====== _ /| /| __ _ / | | /| | @ | | | | / /| |\ | / | | @ | / */ ///* \- || |_| |_ / |/ | | | |_ |- | |--| /-| | | \ \ |==| |- /=| | \ | | |--| | |- */ ///* || | | |_ / | |__| _| |_ \__ | | / | |__ | __| | | | \ / | | \| \__ | | | | \ */ ///* typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pii> vii; typedef vector<vi> vv; const int N = 2e6+4, inf = 1e8; void solve(){ int n; cin >> n; vii a(n); for(int i = 0; i < n; i++){ cin >> a[i].ff >> a[i].ss; }sort(all(a)); int pr[n+1]{}; for(int i = 0; i < n; i++)pr[i+1] = pr[i]+a[i].ss; int ans = a[0].ss-a[0].ff, l = 0, r = 0; while(r < n-1){ if(pr[r+2] - pr[l] - (a[r+1].ff-a[l].ff) > a[r+1].ss-a[r+1].ff)r++; else l = r = r+1; ans = max(ans, pr[r+1] - pr[l] - (a[r].ff - a[l].ff)); } cout << ans << '\n'; } main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int test = 1; //~ cin >> test; while(test--){ solve(); } }

Compilation message (stderr)

art.cpp:40:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   40 | 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...