제출 #412651

#제출 시각아이디문제언어결과실행 시간메모리
412651losmi247선물상자 (IOI15_boxes)C++14
10 / 100
2 ms204 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e3+2; ll n,k,l; int pos[N]; ll kje1(){ ll sol = 0; for(int i = 0; i < n; i++){ ll dod = 2*min(pos[i],(int)l-pos[i]); sol += dod; } return sol; } ll kjen(){ ll sol = l; sol = min(sol,2*(l-pos[0])); for(int i = 0; i < n-1; i++){ ll sta = 2*pos[i]+2*(l-pos[i+1]); sol = min(sol,sta); } return sol; } ll delivery(int br1,int br2,int br3,int *positions){ n = br1; k = br2; l = br3; for(int i = 0; i < n; i++) pos[i] = positions[i]; int sta = 0; while(sta < n && pos[sta] == 0) sta++; if(sta == n) return 0; for(int i = 0; i < n-sta; i++) pos[i] = pos[i+sta]; n -= sta; if(k == 1) return kje1(); if(k == n) return kjen(); }

컴파일 시 표준 에러 (stderr) 메시지

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
#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...