제출 #217838

#제출 시각아이디문제언어결과실행 시간메모리
217838DavidDamian선물상자 (IOI15_boxes)C++11
컴파일 에러
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; }

컴파일 시 표준 에러 (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]);
                   ^~~