제출 #71779

#제출 시각아이디문제언어결과실행 시간메모리
71779zubec선물상자 (IOI15_boxes)C++14
10 / 100
3 ms476 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 10000010; int n, k, l, a[N]; long long delivery(int N, int K, int L, int p[]) { ll ans1 = 0, ans2 = 0; n = N; k = K; l = L; for (int i = 1; i <= n; i++) a[i] = p[i-1]; for (int i = 1; i <= n; i+=k){ int nxt = min(n, i+k-1); ans1 += min(a[i], l-a[i]); ans1 += abs(a[i]-a[nxt]); ans1 += min(a[nxt], l-a[nxt]); } reverse(a+1, a+n+1); for (int i = 1; i <= n; i+=k){ int nxt = min(n, i+k-1); ans2 += min(a[i], l-a[i]); ans2 += abs(a[i]-a[nxt]); ans2 += min(a[nxt], l-a[nxt]); } return min(ans1, ans2); }

컴파일 시 표준 에러 (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]
 long long delivery(int N, int K, int L, int p[]) {
                                                ^
boxes.cpp:6:11: note: shadowed declaration is here
 const int N = 10000010;
           ^
#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...