제출 #290923

#제출 시각아이디문제언어결과실행 시간메모리
290923arayi선물상자 (IOI15_boxes)C++17
100 / 100
646 ms391808 KiB
#include <bits/stdc++.h> #include "boxes.h" #define lli long long int using namespace std; const int N = 1e7 + 20; lli a[N], l; int n, k; lli dp[N], dp1[N], pat = LLONG_MAX, mn[N]; long long delivery(int N, int K, int L, int p[]) { n = N, k = K, l = L; for (int i = 0; i < n; i++) a[i] = p[i]; for (int i = 0; i < n; i++) { dp[i] = a[i] + a[i]; if(i >= k) dp[i] += dp[i - k]; } pat = dp[n - 1]; for(int i = n - 1; i >= 0; i--) { mn[i] = l * 2LL * n; dp1[i] = l - a[i] + l - a[i]; if(n - i > k) dp1[i] += dp1[i + k]; if(i) pat = min(pat, dp1[i] + dp[i - 1]); else pat = min(pat, dp1[0]); } pat = min(dp[n - 1], dp1[0]); mn[n % k] = (n / k) * l; for(int i = n - 1; i >= 0; i--) { mn[i % k] = min(mn[i % k], (i / k) * l + dp1[i]); if(i) { lli sm = dp[i - 1] + mn[i % k] - (i / k) * l; pat = min(pat, sm); } else pat = min(pat, mn[0]); } return pat; }

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

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