제출 #693934

#제출 시각아이디문제언어결과실행 시간메모리
693934T0p_선물상자 (IOI15_boxes)C++14
0 / 100
1 ms468 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[]) { cw[0] = p[0]; for (int i=1 ; i<N ; i++) { cw[i] = cw[i-1]; if (i % K == 0) cw[i] += 2 * p[i-1]; cw[i] += p[i] - p[i-1]; } ccw[N-1] = L - p[N-1]; for (int i=N-2 ; i>=0 ; i--) { ccw[i] = ccw[i+1]; if ((N - i - 1) % K == 0) ccw[i] += 2 * (L - p[i+1]); ccw[i] += p[i+1] - p[i]; } 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[i] + 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...