Submission #30990

#TimeUsernameProblemLanguageResultExecution timeMemory
30990kajebiiiBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
623 ms276172 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define SZ(v) ((int)(v).size()) #define ALL(v) (v).begin(),(v).end() #define one first #define two second typedef long long ll; typedef pair<double, double> pd; typedef pair<int, int> pi; typedef pair<ll, int> pli; typedef pair<ll, ll> pll; typedef pair<ll, pi> plp; typedef tuple<int, int, int> ti; typedef tuple<ll, int, int> tli; const int INF = 0x3f2f1f0f; const ll LINF = 1ll * INF * INF * 2; const int MAX_N = 1e7 + 100; int N, K, L, P[MAX_N]; ll Ls[MAX_N], Rs[MAX_N]; deque<int> Ps; ll delivery(int n, int k, int l, int p[]) { N = n; K = k; L = l; for(int i=0; i<N; i++) Ps.push_back(p[i]); while(SZ(Ps) > 0 && Ps.front() == 0) Ps.pop_front(); for(int i=0; i<SZ(Ps); i++) P[i+1] = Ps[i]; N = SZ(Ps); P[0] = 0; P[N+1] = L; for(int i=1; i<=N; i++) { int ix = max(0, i-K); Ls[i] = Ls[ix] + P[i] + min(P[i], L-P[i]); } for(int i=N; i>=1; i--) { int ix = min(N+1, i+K); Rs[i] = Rs[ix] + L-P[i] + min(P[i], L-P[i]); } ll ans = LINF; for(int i=0; i<=N; i++) { ans = min(ans, Ls[i] + Rs[i+1]); // printf("%d : %lld %lld\n", i, Ls[i], Rs[i+1]); } 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...