Submission #897780

#TimeUsernameProblemLanguageResultExecution timeMemory
897780aqxaBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms2396 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 1e7 + 10; #include "boxes.h" ll ans0[N], ans1[N]; long long delivery(int n, int k, int m, int p[]) { for (int i = 0; i < n; ++i) { if (i < k) { ans0[i] = p[i] + min(p[i], m - p[i]); ans1[n - 1 - i] = (ll) m - p[n - 1 - i] + min((ll)p[n - 1 - i], (ll)m - p[n - 1 - i]); } else { ans0[i] = ans0[i - k] + p[i] + min(p[i], m - p[i]); ans1[n - 1 - i] = ans1[n - 1 - i + k] + (ll) m - p[n - 1 - i] + min((ll)p[n - 1 - i], (ll)m - p[n - 1 - i]); } } ll ans = ans0[n - 1]; for (int i = 0; i < n - 1; ++i) { ans = min(ans, ans0[i] + ans1[i + 1]); } return ans; } // int32_tain() { // ios::sync_with_stdio(false); // cin.tie(nullptr); // int n, k, m; // cin >> n >> k >> m; // int pos[n]; // for (int i = 0; i < n; ++i) { // cin >> pos[i]; // } // cout << "answer: " << delivery(n, k, m, pos) << "\n"; // return 0; // } m
#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...