# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
503405 | mosiashvililuka | Bigger segments (IZhO19_segments) | C++14 | 437 ms | 44284 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,f[500009],i,j,mxf,mxs,pas;
pair <long long, long long> dp[500009];
vector <pair <long long, long long> > v[500009];
int main(){
scanf("%I64d\n",&a);
for(i=1; i<=a; i++) scanf("%I64d",&f[i]);
for(i=1; i<=a; i++) f[i]+=f[i-1];
//scanf("\n");
mxs=1000000000000000000LL;
f[a+1]=mxs;
mxs=0;
for(b=1; b<=a; b++){
for(i=0; i<v[b].size(); i++){
/*if(mxf<v[b][i].first){
mxf=v[b][i].first;mxs=v[b][i].second;
}else{
if(mxf==v[b][i].first&&mxs<v[b][i].second){
mxs=v[b][i].second;
}
}*/
if(mxs<v[b][i].second){
mxf=v[b][i].first;mxs=v[b][i].second;
}else{
if(mxs==v[b][i].second&&mxf<v[b][i].first){
mxf=v[b][i].first;mxs=v[b][i].second;
}
}
}
dp[b].first=1;dp[b].second=f[b];
/*if(mxf>dp[b].first){
dp[b].first=mxf;
dp[b].second=f[b]-mxs;
}else{
if(mxf==dp[b].first&&f[b]-mxs<dp[b].second) dp[b].second=f[b]-mxs;
}*/
if(f[b]-mxs<dp[b].second){
dp[b].first=mxf;
dp[b].second=f[b]-mxs;
}else{
if(f[b]-mxs==dp[b].second&&mxf>dp[b].first){
dp[b].first=mxf;
dp[b].second=f[b]-mxs;
}
}
c=lower_bound(f+1,f+a+1,dp[b].second+f[b])-f;
if(c<=a){
// cout<<b<<" "<<c<<" "<<dp[b].first<<" "<<f[c]<<endl;
v[c].push_back(make_pair(dp[b].first+1,f[b]));
}
if(pas<dp[b].first) pas=dp[b].first;
}
cout<<pas;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |