제출 #693941

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

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:9:24: 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 = 10000000;
      |           ^
#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...