Submission #142941

#TimeUsernameProblemLanguageResultExecution timeMemory
142941daniel920712Boxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include "boxes.h" #include <stdio.h> #include <assert.h> #include <iostream> using namespace std; bool have[10000005]={0}; long long delivery(int N, int K, int L, int p[]) { long long ans=0,t=0,how; int i,l=1e9+7,r=-1,j; for(i=0;i<N;i++) { if(p[i]<(L-p[i])) { if((i+1)%K==0) { ans+=p[i]*2; for(j=i-K+1;j<=i;j++) have[j]=1; //printf("%lld\n",ans); } } else break; } for(i=N-1;i>=0;i--) { if((L-p[i])<p[i]) { if((N-i)%K==0) { ans+=(L-p[i])*2; for(j=i;j-i<K;j++) have[j]=1; //printf("%lld\n",ans); } } else break; } for(j=0;j<N;j++) { if(have[j]==0) { l=min(l,j); r=max(r,j); } } t=1e18; if(r!=-1) { assert((r-l+1)<=2*K) for(i=l;i<r;i++) { if((l-i+1)<=K&&(r-i)<=K) { how=p[i]*2; how+=(L-p[i+1])*2; t=min(t,how); } } if((r-l+1)<=K) { t=min(t,(long long) p[r]*2); t=min(t,(long long) (L-p[l])*2); t=min(t,(long long) L); } t=min(t,(long long) 2*L); ans+=t; } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:50:9: error: expected ';' before 'for'
         for(i=l;i<r;i++)
         ^~~
boxes.cpp:50:18: warning: statement has no effect [-Wunused-value]
         for(i=l;i<r;i++)
                 ~^~
boxes.cpp:50:24: error: expected ';' before ')' token
         for(i=l;i<r;i++)
                        ^
boxes.cpp:10:25: warning: unused variable 'how' [-Wunused-variable]
     long long ans=0,t=0,how;
                         ^~~