제출 #151947

#제출 시각아이디문제언어결과실행 시간메모리
151947erebos선물상자 (IOI15_boxes)C++17
0 / 100
2 ms376 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); } bool cmp(int a, int b) { return tozero(a)>tozero(b); } 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; if(p[i]!=0) { } } } int s, e=-1, i_have=K; for(int i=0; i<n; ++i) { if(p[i]) { if(i_have==K) { s=i; } 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:12:38: warning: unused parameter 'L' [-Wunused-parameter]
 long long delivery(int N, int K, int L, int p[]) {
                                      ^
boxes.cpp:23:6: warning: 's' may be used uninitialized in this function [-Wmaybe-uninitialized]
  int s, e=-1, i_have=K;
      ^
#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...