Submission #712063

#TimeUsernameProblemLanguageResultExecution timeMemory
712063bin9638Shortcut (IOI16_shortcut)C++17
0 / 100
1 ms240 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) { 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]=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=L;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

Compilation message (stderr)

shortcut.cpp: In function 'long long int find_shortcut(int, std::vector<int>, std::vector<int>, int)':
shortcut.cpp:38:17: warning: variable 'vt' set but not used [-Wunused-but-set-variable]
   38 |             int vt=1;
      |                 ^~
#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...