| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1222271 | overwatch9 | Bikeparking (EGOI24_bikeparking) | C++20 | 199 ms | 20372 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int n;
cin >> n;
set <pair <ll, int>> X;
for (int i = 0; i < n; i++) {
int tp;
cin >> tp;
X.insert({i, tp});
}
vector <int> Y(n);
for (int i = 0; i < n; i++)
cin >> Y[i];
ll ans = 0;
for (int i = 0; i < n; i++) {
if (Y[i] == 0)
continue;
while (Y[i] > 0) {
auto it = X.lower_bound({i, 0});
if (it == X.begin())
break;
it--;
int x = it->first;
int id = it->second;
X.erase(it);
int amt = min(x, Y[i]);
Y[i] -= amt;
x -= amt;
ans += amt;
if (x > 0)
X.insert({x, id});
}
}
for (int i = 0; i < n; i++) {
if (Y[i] == 0)
continue;
auto it = X.lower_bound({i, 0});
if (it == X.end() || it->first != i)
ans -= Y[i];
}
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... | ||||
