Submission #30989

#TimeUsernameProblemLanguageResultExecution timeMemory
30989kajebiiiBoxes with souvenirs (IOI15_boxes)C++14
20 / 100
3 ms420 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 cnt = i-1; if(cnt % K == 0) Ls[i] = Ls[i-1] + P[i] * 2; else Ls[i] = Ls[i-1] + (P[i] - P[i-1]) * 2; } for(int i=N; i>=1; i--) { int cnt = N - i; if(cnt % K == 0) Rs[i] = Rs[i+1] + (L-P[i]) * 2; else Rs[i] = Rs[i+1] + (P[i+1] - P[i]) * 2; } for(int i=N; i>=1; i--) { int rix = min(N+1, i+K); Rs[i] = min(Rs[i], Rs[rix] + L); } 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...