Submission #415137

#TimeUsernameProblemLanguageResultExecution timeMemory
415137victoriadBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
2 ms204 KiB
#include "boxes.h"
#include <vector>
 
using namespace std;
 
int n;
long long int dfs(bool b,int K,int box[],int L,int N){
    bool a=false;
    int m=1e9;
for(int i=0;i<N;i++){
    if(box[i]!=-1){
        int x=box[i];
        if(1<=K){
        K-=1;
        if(x<L/2)b=false;
        if(x==L/2)a=true;
        if(x<=L/2)m=x;
        n-=1;
        box[i]=-1;
    }
    if(K==0||n==0){
    if((x<=L/2))return 2*x;
    else if(b){
        if(a)return 2*(L/2);
        else return 2*(L-x);
    }
    else{
        return min(L,2*m+2*(L-x));
    }
    }
    }
}
}
 
long long delivery(int N, int K, int L, int p[]) {
    n=N;
    long long int r=0;
    for(int i=0;i<N;i++){
        if(p[i]==0){
            n--;
        }
        else{
            break;
        }
    }
    while(n>0){
        bool b=true;
        r+=dfs(b,K,p,L,N);
    }
    return r;
}

Compilation message (stderr)

boxes.cpp: In function 'long long int dfs(bool, int, int*, int, int)':
boxes.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
   33 | }
      | ^
#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...