Submission #415239

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

Compilation message (stderr)

boxes.cpp: In function 'long long int dfs(bool, int, int*, long long int, int, int)':
boxes.cpp:18:13: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   18 |     else if(j==1e12){
      |             ^
boxes.cpp:8:10: warning: variable 'a' set but not used [-Wunused-but-set-variable]
    8 |     bool a=false;
      |          ^
boxes.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type]
   48 | }
      | ^
#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...