# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
363582 | 2021-02-06T16:26:05 Z | Sparky_09 | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 364 KB |
#include "bits/stdc++.h" using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define trav(a, x) for(auto& a : x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<ll, ll> pii; typedef vector<ll> vi; typedef vector<pii> vpi; void usaco(string s){ freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } int delivery(int n, int k, int l, int pos[]){ vector<ll> pre(n+2, 0), suf(n+2, 0); for(int i = 1; i <= n; i++){ pre[i] = pre[i-k>=0?i-k:0] + 2 * pos[i-1]; suf[i] = suf[i-k>=0?i-k:0] + 2 * (l - pos[n-i]); } ll ans = 1e18; for(int i = 0; i <= n; i++){ ans = min(ans, min({pre[i] + suf[n-i-k>0?n-i-k:0] + l, pre[i] + suf[n-i]})); } reverse(pos, pos + n); vector<ll> pre1(n+2, 0), suf1(n+2, 0); for(int i = 1; i <= n; i++){ pre1[i] = pre1[i-k>=0?i-k:0] + 2 * pos[i-1]; suf1[i] = suf1[i-k>=0?i-k:0] + 2 * (l - pos[n-i]); } for(int i = 0; i <= n; i++){ ans = min(ans, min({pre1[i] + suf1[n-i-k>0?n-i-k:0] + l, pre1[i] + suf1[n-i]})); } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |