# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1075286 | 2024-08-26T01:06:02 Z | mochifr | Garage (IOI09_garage) | C++17 | 2 ms | 432 KB |
#include <bits/stdc++.h> #include <queue> #include <vector> using namespace std; typedef long long ll; int main() { int n, m; cin >> n >> m; vector<int> slot_prices(n); vector<int> car_weights(m); for (int i = 0; i < n; i++) cin >> slot_prices[i]; for (int i = 0; i < m; i++) cin >> car_weights[i]; set<int> available_slots; for (int i = 0; i < n; i++) { available_slots.insert(i); } vector<int> taken_slot(m, 0); queue<int> car_queue; int money = 0; for (int i = 0; i < 2 * m; i++) { int c; cin >> c; if (c > 0) { c--; if (available_slots.empty()) { car_queue.push(c); continue; } int s = *available_slots.begin(); int sc = s; available_slots.erase(s); taken_slot[c] = sc; money += car_weights[c] * slot_prices[sc]; } else if (c < 0) { c = -c; c--; available_slots.insert(taken_slot[c]); if (!car_queue.empty()) { int oc = c; c = car_queue.front(); car_queue.pop(); int s = *available_slots.begin(); int sc = s; available_slots.erase(s); taken_slot[c] = sc; money += car_weights[c] * slot_prices[sc]; } } else { cout << "?" << endl; } } cout << money << endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 432 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 388 KB | Output is correct |
18 | Correct | 2 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 2 ms | 348 KB | Output is correct |