제출 #618922

#제출 시각아이디문제언어결과실행 시간메모리
618922A_D선물상자 (IOI15_boxes)C++14
10 / 100
1 ms340 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; const int N=1e7+10; long long pre[N]; long long suf[N]; long long delivery(int N, int K, int L, int p[]) { long long ans=1e18; long long me=0,cur=0,lst=0; for(int i=0;i<N;i++){ long long h=p[i]; me+=h-lst; cur++; pre[i]=me+min(h,L-h); if(cur==K){ me+=min(h,L-h); cur=0; me+=min(h,L-h); } lst=p[i]; } ans=pre[N-1]; me=0,cur=0,lst=L; for(int i=N-1;i>=0;i--){ long long h=p[i]; me+=abs(h-lst); cur++; suf[i]=me+min(h,L-h); if(cur==K){ me+=min(h,L-h); cur=0; me+=min(h,L-h); } lst=p[i]; } for(int i=0;i<N-1;i++){ ans=min(ans,pre[i]+suf[i+1]); } return ans; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:18:24: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   18 | long long delivery(int N, int K, int L, int p[]) {
      |                    ~~~~^
boxes.cpp:10:11: note: shadowed declaration is here
   10 | const int N=1e7+10;
      |           ^
#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...