This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "boxes.h"
#include <vector>
using namespace std;
int n;
int dfs(int nodo,bool b,int &K,vector<int>&box,int L){
if(box[nodo]<=K){
K-=box[nodo];
if(box[nodo]!=0 && nodo<=L/2)b=false;
n-=box[nodo];
box[nodo]=0;
}
else{
if(nodo<=L/2)b=false;
box[nodo]-=K;
K=0;
n-=K;
}
if(K!=0 && n!=0 && nodo!=L-1){
return dfs(nodo+1,b,K,box,L);
}
else{
if(nodo<=L/2)return 2*nodo;
else if(b){
return 2*(L-nodo);
}
else{
return L;
}
}
}
long long delivery(int N, int K, int L, int p[]) {
vector<int>box(L,0);
for(int i=0;i<N;i++){
box[p[i]]++;
}
n=N;
long long int r=0;
while(n>0){
bool b=true;
int k=K;
r+=dfs(0,b,k,box,L);
}
return r;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |