Submission #242687

#TimeUsernameProblemLanguageResultExecution timeMemory
242687lycBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
5 ms384 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define TRACE(x) cerr << #x << " :: " << x << endl #define _ << " " << #define FOR(i,a,b) for(int i=(a);i<=(b);++i) #define RFOR(i,a,b) for(int i=(a);i>=(b);--i) #define SZ(x) ((int)(x).size()) #define ALL(x) (x).begin(),(x).end() using ll=long long; const int mxN = 1e7; ll d[mxN]; ll delivery(int N, int K, int L, int p[]) { int half = -1; FOR(i,0,N-1){ if (p[i]*2 <= L) d[i] = (i < K ? 0 : d[(i/K)*K-1]) + p[i], half = i; else d[i] = (N-1-i < K ? 0 : d[N-1-((N-1-i)/K*K-1)]) + (L-p[i]); } d[N] = 0; ll ans = 2*d[half] + 2*d[half+1]; FOR(i,0,min(half,N-K)){ if (i == N-K || p[i+K]*2 > L) { ans = min(ans,2*(i > 0 ? d[i-1] : 0)+L+2*d[i+K]); } } //TRACE(ans); return ans; }
#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...