Submission #386606

#TimeUsernameProblemLanguageResultExecution timeMemory
386606KeshiBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms364 KiB
//In the name of God #include <bits/stdc++.h> #include "boxes.h" using namespace std; typedef long long ll; typedef pair<ll, ll> pll; const ll maxn = 1e7 + 100; const ll mod = 1e9 + 7; const ll inf = 1e18; #define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout); #define pb push_back #define Mp make_pair #define F first #define S second #define Sz(x) ll((x).size()) #define all(x) (x).begin(), (x).end() ll dp1[maxn], dp2[maxn], mn[maxn]; long long delivery(int n, int k, int L, int p[]) { for(ll i = 0; i < k; i++){ dp1[i] = p[i] * 2; dp2[n - 1 - i] = (L - p[n - 1 - i]) * 2; } for(ll i = k; i < n; i++){ dp1[i] = dp1[i - k] + p[i] * 2; dp2[n - 1 - i] = dp2[n - 1 - i + k] + (L - p[n - 1 - i]) * 2; } fill(mn, mn + k, inf); ll ans = min(dp1[n - 1], dp2[0]); for(ll i = 0; i < n; i++){ ans = min(ans, L * ((i - 1) / k) + mn[(i - 1 + k) % k] + dp2[i]); mn[i % k] = min(mn[i % k], dp1[i] - L * (i / k)); } return ans; } /*int main(){ fast_io; return 0; }*/
#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...