Submission #247380

#TimeUsernameProblemLanguageResultExecution timeMemory
247380uacoder123Divide and conquer (IZhO14_divide)C++14
0 / 100
5 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i) #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) #define mp(i,a) make_pair(i,a) #define pb(a) push_back(a) #define bit(x,b) (x&(1LL<<b)) typedef long long int lli; typedef pair <lli,lli> ii; typedef pair <lli,ii> iii; typedef vector <lli> vi; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int test=1,co=0; for(;test>0;--test) { lli n,ans=0; cin>>n; lli g[n+1]={},arr[n+1]={},arr1[n+1]={},arr2[n+1]={}; vector<ii> p(n+1); p[0]=mp(0,0); for(lli i=1;i<=n;++i) { lli y; cin>>arr1[i]>>g[i]>>y; p[i].S=i; p[i].F=p[i-1].F+y-arr1[i]+arr1[i-1]; arr2[i]=arr2[i-1]+y; g[i]+=g[i-1]; } sort(p.begin()+1,p.end()); for(lli i=n;i>=1;--i) { if(i==n) arr[i]=p[i].S; else arr[i]=max(arr[i+1],p[i].S); } for(lli i=1;i<=n;++i) { lli a=-(arr1[i]-arr1[1]-arr2[i-1]); auto it=lower_bound(p.begin()+1,p.end(),mp(a,0*1LL))-p.begin(); if(it!=n+1) ans=max(ans,g[arr[it]]-g[i-1]); } cout<<ans<<endl; } return(0); }

Compilation message (stderr)

divide.cpp: In function 'int main()':
divide.cpp:21:14: warning: unused variable 'co' [-Wunused-variable]
   int test=1,co=0;
              ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...