제출 #290904

#제출 시각아이디문제언어결과실행 시간메모리
290904arayi선물상자 (IOI15_boxes)C++17
50 / 100
54 ms18296 KiB
#include <bits/stdc++.h> #include "boxes.h" #define lli long long int using namespace std; const int N = 1e4 + 20; lli a[N], l; int n, k; lli dp[N], dp1[N], pat = LLONG_MAX; 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--) { 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]); } for (int l = 0; l < n; l++) { for (int r = l; r < n; r++) { lli sm = ((r - l) / k + 1) * 1LL * L; if(l) sm += dp[l - 1]; if(r < n - 1) sm += dp1[r + 1]; pat = min(pat, sm); } } 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 = 1e4 + 20;
      |           ^
boxes.cpp:26:14: warning: declaration of 'l' shadows a global declaration [-Wshadow]
   26 |     for (int l = 0; l < n; l++)
      |              ^
boxes.cpp:6:11: note: shadowed declaration is here
    6 | lli a[N], l;
      |           ^
#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...