| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1353914 | sally | Bikeparking (EGOI24_bikeparking) | C++20 | 1096 ms | 9712 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int N;
cin >> N;
vector<int> x(N), y(N);
for (auto &i : x) cin >> i;
for (auto &i : y) cin >> i;
int l = 0, r = 0;
for (int i = 0; i < N; i++) r += x[i];
vector<int> slot = x;
int ans = 0;
// 用 greedy:從小 s 到大 s
vector<int> rem = x;
int ptr = 0;
for (int s = 0; s < N; s++) {
int need = y[s];
// 1) 先吃 t < s (+1)
for (int t = 0; t < s && need; t++) {
int take = min(rem[t], need);
ans += take;
rem[t] -= take;
need -= take;
}
// 2) 再吃 t = s (0)
int take = min(rem[s], need);
rem[s] -= take;
need -= take;
// 3) 最後只能吃 t > s (-1)
for (int t = s + 1; t < N && need; t++) {
int take = min(rem[t], need);
ans -= take;
rem[t] -= take;
need -= take;
}
}
cout << ans << "\n";
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
