Submission #146724

#TimeUsernameProblemLanguageResultExecution timeMemory
146724karmaBoxes with souvenirs (IOI15_boxes)C++11
10 / 100
3 ms504 KiB
#include <bits/stdc++.h> #include "boxes.h" #define ll long long using namespace std; const int N = int(1e7); ll f[N]; int mid, g; ll delivery(int n, int k, int l, int pos[]) { mid = l >> 1; for(int i = 0; i < n; ++i) { if(pos[i] <= mid) { if(i >= k) f[i] = f[i - k] + min(2 * pos[i], l); else f[i] = min(2 * pos[i], l); } else { if(i >= k) f[i] = f[i - k] + min(l, 2 * (l - pos[i - k + 1])); else f[i] = min(l, 2 * (l - pos[i - k + 1])); } } return f[n - 1]; } /*int _n, _k, _l, _pos[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); if(fopen("test.inp", "r")) { freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } cin >> _n >> _k >> _l; for(int i = 0; i < _n; ++i) cin >> _pos[i]; cout << delivery(_n, _k, _l, _pos); }*/
#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...