제출 #71781

#제출 시각아이디문제언어결과실행 시간메모리
71781zubec선물상자 (IOI15_boxes)C++14
100 / 100
530 ms235208 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 10000010; int n, k, l, a[N]; long long dp1[N], dp2[N]; long long delivery(int N, int K, int L, int p[]) { ll ans = 1e15; n = N; k = K; l = L; for (int i = 1; i <= n; i++) a[i] = p[i-1]; for (int i = 1; i <= n; i++){ int pre = max(0, i-k); dp1[i] = dp1[pre] + min((ll)l, a[i]*1LL*2); } for (int i = n; i >= 1; i--){ int nxt = min(n+1, i+k); dp2[i] = dp2[nxt] + min((ll)l, (l-a[i])*1LL*2); } for (int i = 0; i <= n; i++){ ans = min(ans, dp1[i]+dp2[i+1]); } return ans; }

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

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