Submission #138788

#TimeUsernameProblemLanguageResultExecution timeMemory
138788dnassBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
2083 ms376 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; long long delivery(int N, int K, int L, int p[]){ lld cost = 0; n = N; k = K; l = L; if(n==1) return min((lld)2*p[0], (lld)2*(l-p[0])); for(int i=0;2*p[i]<=l;i++){ lhalf.push_back(p[i]); } lsize = (int) lhalf.size(); for(int i=n-1;2*(l-p[i])<l;i--){ rhalf.push_back(l-p[i]); } rsize = (int) rhalf.size(); if(2*lhalf[lsize-1]+2*rhalf[rsize-1]<=l){ int pos_right = rsize-1; int pos_left = lsize-1; while(pos_right>=0){ cost += 2*rhalf[pos_right]; pos_right -= k; } while(pos_left>=0){ cost += 2*lhalf[pos_left]; pos_left -= k; } }else{ while(true){} } 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...