제출 #65560

#제출 시각아이디문제언어결과실행 시간메모리
65560daniel_02선물상자 (IOI15_boxes)C++17
100 / 100
518 ms196072 KiB
#include "boxes.h" #include <bits/stdc++.h> #define ll long long using namespace std; const int N = 1e7 + 3; ll dp[N], dp_suf[N]; long long delivery(int N, int K, int L, int p[]) { long long ans, res = 0; ans = 1LL * 1e18 + 7; for (int i = 0; i < N; i++) { if (i < K) { dp[i] = p[i] + min(L - p[i], p[i]); } else { dp[i] = (p[i] + min(L - p[i], p[i])) + dp[i - K]; } } for (int i = N - 1; i >= 0; i--) { if (N - i - 1 < K) { dp_suf[i] = (L - p[i]) + min(L - p[i], p[i]); } else { dp_suf[i] = ((L - p[i]) + min(L - p[i], p[i])) + dp_suf[i + K]; } } for (int i = 0; i < N; i++){ ans = min(ans, dp[i] + dp_suf[i + 1]); } for (int i = 0; i < N; i += K) { res += (L - p[i]) + min(p[i], L - p[i]); } ans = min(ans, res); return ans; return ans; }

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

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