Submission #699729

#TimeUsernameProblemLanguageResultExecution timeMemory
699729Mo7amed_HossamArt Exhibition (JOI18_art)C++17
0 / 100
1 ms212 KiB
/* * created by Mohamed hossam #### #### ## ## ## ## ## ## ##### ## ## ###### ## ## ## ## ## ## ## ####### ############## ## ## ######## ## ###### ## ## ## ####### ############## ######### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ### ### ##### ## ## ## ## ## ####### ######## */ #include <bits/stdc++.h> #define ll long long #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; int main() { fast; ll n; cin>>n; pair<ll,ll>a[n]; for(ll i=0; i<n; i++) { cin>>a[i].first>>a[i].second; } /* 1 5 4 1 4 2 5 3 9 1 10 3 */ sort(a,a+n); ll k=0,x=-1,z=0; for(ll i=0; i<n; i++) { k+=a[i].second; x=max(x,k-(a[i].first-a[0].first)); z=max(z,a[i].second); } k=0; for(ll i=0; i<n-1; i++) { x=max(x,(a[i].second+a[i+1].second)-(a[i+1].first-a[i].first)); } cout<<max(x,z)<<"\n"; return 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...