제출 #151948

#제출 시각아이디문제언어결과실행 시간메모리
151948erebos선물상자 (IOI15_boxes)C++17
0 / 100
2 ms508 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; using ll=long long int; int n; inline int tozero(int idx) { return min(idx, n-idx); } long long delivery(int N, int K, int L, int p[]) { n=N; ll ans=0; for(int i=0; i<n; ++i) { if(p[i]>=K) { ans+=(p[i]/K)*(tozero(i)*2); p[i]%=K; } } int s, e=-1, i_have=K; for(int i=0; i<n; ++i) { if(p[i]) { if(i_have==K) { s=i; } else if(i_have>p[i]) { i_have-=p[i]; e=i; } else if(i_have==p[i]) { i_have=K; ans+=tozero(s)+tozero(i); e=-1; } else { s=i; i_have=i_have+K-(p[i]); ans+=tozero(s)+tozero(i); e=-1; } } } if(e!=-1) { ans+=tozero(e); } return ans; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:9:38: warning: unused parameter 'L' [-Wunused-parameter]
 long long delivery(int N, int K, int L, int p[]) {
                                      ^
#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...