Submission #217838

#TimeUsernameProblemLanguageResultExecution timeMemory
217838DavidDamianBoxes with souvenirs (IOI15_boxes)C++11
Compilation error
0 ms0 KiB
//#include "boxes.h" using namespace std; typedef long long ll; long long delivery(int N, int K, int L, int p[]) { ll total=0; int remaining=K; int a=0,b=N-1; int last=-1; while(a<=b){ ll distA; ll distB; int selected=0; if(remaining==K){ distA=min(p[a],L-p[a]); distB=min(p[b],L-p[b]); if(distA<=distB) selected=a; else selected=b; total+=(selected==a)? distA : distB; } else{ distA=min(abs(p[a]-p[last]),L-abs(p[a]-p[last])); distB=min(abs(p[b]-p[last]),L-abs(p[b]-p[last])); if(distA<=distB) selected=a; else selected=b; total+=(selected==a)? distA : distB; } remaining--; if(remaining==0 || a==b){ distA=min(p[a],L-p[a]); distB=min(p[b],L-p[b]); total+=(selected==a)? distA : distB; remaining=K; } last=selected; if(selected==a) a++; else b--; } return total; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:14:19: error: 'min' was not declared in this scope
             distA=min(p[a],L-p[a]);
                   ^~~
boxes.cpp:21:23: error: 'abs' was not declared in this scope
             distA=min(abs(p[a]-p[last]),L-abs(p[a]-p[last]));
                       ^~~
boxes.cpp:21:19: error: 'min' was not declared in this scope
             distA=min(abs(p[a]-p[last]),L-abs(p[a]-p[last]));
                   ^~~
boxes.cpp:29:19: error: 'min' was not declared in this scope
             distA=min(p[a],L-p[a]);
                   ^~~