Submission #712067

#TimeUsernameProblemLanguageResultExecution timeMemory
712067bin9638Shortcut (IOI16_shortcut)C++17
23 / 100
2053 ms336 KiB
#include <bits/stdc++.h> #ifndef SKY #include "shortcut.h" #endif // SKY using namespace std; #define ll long long #define pb push_back #define N 100010 #define ii pair<ll,int> #define fs first #define sc second int n; ll sum[N],C,d[N]; ll dis(int u,int v,int L,int R) { if(u==v) return 0; return d[u]+d[v]+min(abs(sum[u]-sum[v]),min( abs(sum[L]-sum[u])+abs(sum[R]-sum[v])+C, abs(sum[L]-sum[v])+abs(sum[R]-sum[u])+C )); } ll find_shortcut(int cc, vector<int> l, vector<int> DD, int vl) { n=cc; C=vl; for(int i=2;i<=n;i++) sum[i]=1ll*l[i-2]+sum[i-1]; for(int i=1;i<=n;i++) d[i]=DD[i-1]; ll res=1e18; for(int L=1;L<=n;L++) for(int R=1;R<=n;R++) { // if(L==2&&R==4) // cout<<dis(2,4,L,R)<<endl; /* int vt=1; ll val=0; for(int i=2;i<=n;i++) { ll cc=dis(1,i,L,R); if(cc>val) { val=cc; vt=i; } }*/ ll D=0; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) D=max(D,dis(j,i,L,R)); res=min(res,D); } return res; } #ifdef SKY int main() { freopen("A.inp","r",stdin); freopen("A.out","w",stdout); int n,c; vector<int>l,d; cin>>n; for(int i=0;i<n-1;i++) { int u; cin>>u; l.pb(u); } for(int i=0;i<n;i++) { int u; cin>>u; d.pb(u); } cin>>c; cout<<find_shortcut(n,l,d,c); } #endif
#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...