Submission #419158

#TimeUsernameProblemLanguageResultExecution timeMemory
419158LouayFarahBoxes with souvenirs (IOI15_boxes)C++14
20 / 100
1 ms204 KiB
#include "bits/stdc++.h" #include "boxes.h" using namespace std; long long min(long long a, long long b) { if(a>=b) return b; return a; } long long delivery(int n, int k, int l, int positions[]) { if(k==1) { long long res = 0; for(int i = 0; i<n; i++) { if(positions[i]>l/2) { res+=2*(l-positions[i]); } else { res+=2*(positions[i]); } } return res; } else if(k==n) { long long a = 0, b = 0, c = 0, d = 1e18; a = l; b = 2*positions[n-1]; c = 2*(l - positions[0]); long long left = -1, right = 0; for(int i = 0; i<n; i++) { if(positions[i]>=l/2) { if(i>0) { left = positions[i]; right = positions[i-1]; break; } else break; } } if(left!=-1) d = 2*(l - left) + 2*right; return min(min(a,b), min(c, d)); } else { } }

Compilation message (stderr)

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