Submission #138734

#TimeUsernameProblemLanguageResultExecution timeMemory
138734dnassBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
2 ms376 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long int lld; int n, k, l; long long delivery(int N, int K, int L, int p[]){ lld cost = 0; n = N; k = K; l = L; int esq = 0, dir = n-1; while(esq<=dir){ lld cost_esq, cost_dir; cost_esq = min(2*((lld)p[min(esq+k-1, dir)]), (lld) l); cost_dir = min(2*((lld)(l-p[max(dir-k+1, esq)])), (lld) l); if(cost_esq<cost_dir){ cost += cost_esq; esq = min(esq+k-1, dir)+1; }else{ cost += cost_dir; dir = max(dir-k+1, esq)-1; } //cout << "esq: " << cost_esq << endl; //cout << "dir: " << cost_dir << endl; //cout << cost << endl; } 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...