# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
600499 |
2022-07-20T23:29:53 Z |
A_D |
Shortcut (IOI16_shortcut) |
C++14 |
|
0 ms |
212 KB |
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+100;
long long pre[N];
long long suf[N];
long long cc;
long long tot=0;
long long ok1(int u,int l,int r)
{
long long ret1=pre[u];
long long ret2=suf[u]-suf[r]+cc+pre[l];
return min(ret1,ret2);
}
long long ok2(int u,int l,int r)
{
long long ret1=suf[u];
long long ret2=pre[u]-pre[l]+cc+suf[r];
return min(ret1,ret2);
}
long long con(int l,int r)
{
long long ret=min(pre[l]+suf[r]+cc,tot);
long long l1=l,r1=r;
while(l1<=r1){
int mid=(l1+r1)/2;
long long u=ok1(mid,l,r);
long long v=ok1(mid+1,l,r);
ret=max(ret,u);
ret=max(ret,v);
if(u>v){
r1=mid-1;
}
else{
l1=mid+2;
}
}
l1=l,r1=r;
while(l1<=r1){
int mid=(l1+r1)/2;
long long u=ok2(mid,l,r);
long long v=ok2(mid+1,l,r);
ret=max(ret,u);
ret=max(ret,v);
if(u>v){
r1=mid-1;
}
else{
l1=mid+2;
}
}
return ret;
}
long long find_shortcut(int n,vector<int> l,vector<int> d,int c)
{
cc=c;
pre[0]=d[0];
for(int i=1;i<n;i++){
pre[i]=max(pre[i-1]+(long long)l[i-1],(long long)d[i]);
}
tot=pre[n-1]+d[n-1];
suf[n-1]=d[n-1];
for(int i=n-1-1;i>=0;i--){
suf[i]=max(suf[i+1]+(long long)l[i],(long long)d[i+1]);
}
long long ans=1e18;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
ans=min(ans,con(i,j));
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
n = 4, incorrect answer: jury 80 vs contestant 70 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
n = 4, incorrect answer: jury 80 vs contestant 70 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
n = 4, incorrect answer: jury 80 vs contestant 70 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
n = 4, incorrect answer: jury 80 vs contestant 70 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
n = 4, incorrect answer: jury 80 vs contestant 70 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
n = 4, incorrect answer: jury 80 vs contestant 70 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
n = 4, incorrect answer: jury 80 vs contestant 70 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
n = 4, incorrect answer: jury 80 vs contestant 70 |
2 |
Halted |
0 ms |
0 KB |
- |