Submission #242731

#TimeUsernameProblemLanguageResultExecution timeMemory
242731lycBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
519 ms174164 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]) + p[i], half = i; } else break; } RFOR(i,N-1,0){ if (p[i]*2 > L) { d[i] = (N-1-i < K ? 0 : d[i+K]) + (L-p[i]); } else break; } 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...