Submission #463669

#TimeUsernameProblemLanguageResultExecution timeMemory
463669Blobo2_Blobo2Art Exhibition (JOI18_art)C++14
0 / 100
1 ms308 KiB
/* Editor: Abdelrahman Hossam Nickname: Blobo2_Blobo2 IOI next year isA :) */ #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-funroll-loops") #pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops") #include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" #define all(v) v.begin(),v.end() #define gen(arr,n,nxt) generate(arr,arr+n,nxt) #define Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty ios_base::sync_with_stdio(false);cin.tie(0); const int mo=1e9+7,INF=1e18; int nxt(){int x;cin>>x;return x;} signed main(){ Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty int n=nxt(); vector<pair<int,int> >v; for(int i=0;i<n;i++) v.push_back({nxt(),nxt()}); sort(all(v)); int mx=v[0].second,ans=v[0].second,l=0; for(int i=1;i<n;i++){ ans+=v[i].second; int x = ans - (v[i].first-v[l].first); while(l+1<=i&&x < (ans-v[l].second) - (v[i].first-v[l+1].first)) l++,ans-=v[l-1].second,x = ans - (v[i].first-v[l].first); mx=max(x,mx); } cout<<mx; 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...