Submission #106116

#TimeUsernameProblemLanguageResultExecution timeMemory
106116HideoBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
4 ms384 KiB
#include <bits/stdc++.h> //#include "grader.cpp" #include "boxes.h" using namespace std; #define ll long long #define pb push_back #define mk make_pair #define fr first #define sc second #define vi vector < int > #define vl vector < ll > #define pi pair < int, int > #define pii pair < int, pi > #define vii vector < pi > const int MAXN = 1e7 + 7; const ll INF = 1e18 + 7; ll pr[MAXN], sf[MAXN]; ll ans; long long delivery(int N, int K, int L, int p[]) { for (int i = 0; i < K; i++){ for (int j = 0; i + j * K < N; j++){ if (j) pr[i + j * K] = pr[i + (j - 1) * K] + p[i + j * K] + min(p[i + j * K], L - p[i + j * K]); else pr[i + j * K] = p[i + j * K] + min(p[i + j * K], L - p[i + j * K]); } } for (int i = N - 1; i >= 0; i--){ for (int j = 0; i - j * K >= 0; j++){ if (j) sf[i - j * K] = sf[i - (j - 1) * K] + L - p[i - j * K] + min(p[i - j * K], L - p[i - j * K]); else sf[i - j * K] = L - p[i - j * K] + min(p[i - j * K], L - p[i - j * K]); } } ans = sf[0]; for (int i = 0; i < N; i++) ans = min(ans, pr[i] + sf[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...