# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1012083 |
2024-07-01T15:38:18 Z |
deera |
Garage (IOI09_garage) |
C++14 |
|
2 ms |
604 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
// freopen("2009/garage.txt", "r", stdin);
ll n, m;
cin >> n >> m;
vector<ll> places(n);
for (int i = 0; i < n; i++)
cin >> places[i];
vector<ll> weights(m);
for (int i = 0; i < m; i++)
cin >> weights[i];
ll total = 0;
queue<ll> waiting;
priority_queue<pair<ll, ll>> avail;
map<ll, ll> booked;
for (int i = 0; i < n; i++) {
avail.push({-i, i});
}
for (int i = 0; i < m*2; i++) {
ll car;
cin >> car;
if (car < 0) {
car = -car;
car--;
ll place = booked[car];
avail.push({-place, place});
} else {
car--;
waiting.push(car);
}
while (avail.size() != 0 && waiting.size() != 0) {
ll next = waiting.front();
waiting.pop();
ll weight = weights[next];
pair<ll, ll> spot = avail.top();
avail.pop();
ll rate = places[spot.second];
booked[car] = spot.second;
total += rate * weight;
}
}
cout << total;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
17 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
18 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
19 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
20 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |