Submission #1030970

#TimeUsernameProblemLanguageResultExecution timeMemory
1030970kymShortcut (IOI16_shortcut)C++14
0 / 100
0 ms348 KiB
#include "shortcut.h" #include <bits/stdc++.h> using namespace std; #define int long long const int maxn=3005; int X[maxn]; vector<int32_t> L, D; int C; int n; const int oo = 1'000'000'000'000'000'000ll; typedef pair<int,int>pi; int get(int L, int R){ int dl=0,dr=0; for(int i=0;i<=L;i++)dl=max(dl,-X[i]+D[i]); for(int i=R;i<n;i++)dr=max(dr,X[i]+D[i]); int ans=0; ans=max(ans,dl+dr+min(X[R]-X[L],C)+X[L]-X[R]); int m1=0; for(int i=L;i<=R;i++){ m1=max(m1,D[i] + min(X[i]-X[L], X[R]-X[i]+C)); } ans=max(ans,m1 + dl+X[L]); int m2=0; for(int i=L;i<=R;i++){ m2=max(m2,D[i] + min(X[R]-X[i], X[i]-X[L]+C)); } ans=max(ans,m2+dr-X[R]); int bet=0; for(int i=L;i<=R;i++){ for(int j=i+1;j<=R;j++){ bet=max(bet,D[i]+D[j]+min(X[j]-X[i],C+X[i]-X[L]+X[R]-X[j])); } } ans=max(ans,bet); //ans=max(ans,longest(ls)); //what if they just don't use it m1=0,m2=0; for(int i=0;i<=L;i++){ m1=max(m1,X[i]+D[i]); m2=max(m2,-X[i]+D[i]); } ans=max(ans,m1+m2); m1=0,m2=0; for(int i=R;i<n;i++){ m1=max(m1,X[i]+D[i]); m2=max(m2,-X[i]+D[i]); } ans=max(ans,m1+m2); return ans; } long long find_shortcut(int32_t n, vector<int32_t> l, vector<int32_t> d, int32_t c) { L=l;D=d;C=c; ::n=n; for(int i=1;i<n;i++){ X[i]=X[i-1]+l[i-1]; } int ans=oo; for(int i=0;i<n;i++){ for(int j=i;j<n;j++){ ans=min(ans,get(i,j)); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...