제출 #140000

#제출 시각아이디문제언어결과실행 시간메모리
140000TAMREF선물상자 (IOI15_boxes)C++11
10 / 100
8 ms380 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; using ll = long long; ll *ds, *de; ll delivery(int N, int K, int L, int p[]) { int s = 0, e = N - 1, k = K; while(s <= e && p[s] == 0) ++s; ds = new ll[N+1]; de = new ll[N+1]; memset(ds,0,sizeof(ds)); memset(de,0,sizeof(de)); if(s > e) return 0; ll t = LLONG_MAX; int si = s; e = s; de[N] = 0; for(int i = N; i--;){ de[i] = L - p[i]; if(i + k < N) de[i] += de[i+k]; } t = 2ll * de[si]; for(; s < N; s++){ ds[s] = p[s]; if(s-k >= si) ds[s] += ds[s-k]; for(e = s; e < N; e++) t = min(t, 2ll * (ds[s] + de[e+1]) + ll(e-s+k-1)/k * L); } //for(int i = 0; i <= N; i++) cout << ds[i] << ' '; cout << endl; //for(int i = 0; i <= N; i++) cout << de[i] << ' '; cout << endl; return t; }

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

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:13:23: warning: argument to 'sizeof' in 'void* memset(void*, int, size_t)' call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
     memset(ds,0,sizeof(ds));
                       ^
boxes.cpp:14:23: warning: argument to 'sizeof' in 'void* memset(void*, int, size_t)' call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
     memset(de,0,sizeof(de));
                       ^
#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...