제출 #778082

#제출 시각아이디문제언어결과실행 시간메모리
778082Jarif_Rahman선물상자 (IOI15_boxes)C++17
100 / 100
641 ms338916 KiB
#include "boxes.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; const int K = 1e7; ll S[K]; ll delivery(int n, int k, int L, int P[]){ vector<ll> A(n+1), B(n+1); A[0] = 0, B[n] = 0; fill(S, S+k, 0); for(int i = 1; i <= n; i++){ S[i%k]+=2*P[i-1]; A[i] = S[i%k]; } fill(S, S+k, 0); for(int i = n-1; i >= 0; i--){ S[(n-i)%k]+=2*(L-P[i]); B[i] = S[(n-i)%k]; } vector<ll> C(n+1); C[n] = 0; for(int i = n-1; i >= 0; i--){ C[i] = ll((n-i+k-1)/k)*L; C[i] = min(C[i], B[i]); if(i+k <= n) C[i] = min(C[i], C[i+k]+L); } ll ans = 1e18; for(int i = 0; i <= n; i++) ans = min(ans, A[i]+C[i]); return ans; }
#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...