Submission #138823

#TimeUsernameProblemLanguageResultExecution timeMemory
138823dnassBoxes with souvenirs (IOI15_boxes)C++14
50 / 100
2041 ms27952 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long int lld; int n, k, l; vector<int> lhalf, rhalf; int lsize, rsize; vector<lld> beg_l, beg_r; long long delivery(int N, int K, int L, int p[]){ lld cost = 1e18; n = N; k = K; l = L; if(n==1) return min((lld)2*p[0], (lld)2*(l-p[0])); for(int i=0;i<n&&2*p[i]<=l;i++){ lhalf.push_back(p[i]); } lsize = (int) lhalf.size(); for(int i=n-1;i>=0&&2*(l-p[i])<l;i--){ rhalf.push_back(l-p[i]); } rsize = (int) rhalf.size(); beg_l.push_back(0); for(int i=0;i<lsize;i++){ beg_l.push_back(2*((lld)lhalf[i])+beg_l[max(0, i-k+1)]); } beg_r.push_back(0); for(int i=0;i<rsize;i++){ beg_r.push_back(2*((lld)rhalf[i])+beg_r[max(0, i-k+1)]); } for(int i=0;i<rsize+1;i++){ for(int j=0;j<lsize+1;j++){ if((n-i-j)%k==0){ cost = min(cost, ((lld)((n-i-j)/k))*((lld)l)+beg_l[j]+beg_r[i]); } } } return cost; }
#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...