제출 #81679

#제출 시각아이디문제언어결과실행 시간메모리
81679wzy선물상자 (IOI15_boxes)C++11
0 / 100
8 ms376 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; long long dpL[10000001] , dpR[10000001]; long long delivery(int N, int K, int L, int p[]) { #define int long long int ans = (int) 1e18; int k = K; int n = N; int l = L; for(int i = 0 ; i < N ;i ++){ dpL[i] = 2*p[i]; if(i >= K) dpL[i] = dpL[i-k] + 2*p[i]; // pick the last block and then solve for [0 , i-k] } for(int j = N - 1 ; j >= 0 ; j--){ int u = j + K ; dpR[j] = 2*(L - p[j]); if(u <= n - 1) dpR[j] = dpR[u] + 2*(L - p[j]); } for(int j = N - 1 ; j >= 0 ; j--){ for(int r = 0 ; (j - k*r + 1) >= 0 ; r++){ int u = j - k*r + 1; if(u > j) continue; ans = min(ans ,dpL[u] + dpR[j] + L*((j-u+1)/k + ((j-u+1)%k ? 1 : 0))); } ans = min(ans , dpR[j] + L*((j)/k + (j%k ? 1 : 0))); int i = j; ans = min(ans ,dpL[j] + L *((n-i-1)/k + ((n-i-1)%k ? 1 : 0))); } return ans; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:12:6: warning: unused variable 'l' [-Wunused-variable]
  int l = 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...