# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
703382 |
2023-02-27T08:13:09 Z |
finn__ |
Garage (IOI09_garage) |
C++17 |
|
2 ms |
340 KB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
size_t n, m;
cin >> n >> m;
queue<unsigned> q_car;
priority_queue<pair<unsigned, unsigned>> q_lot;
for (size_t i = 0; i < n; i++)
{
unsigned s;
cin >> s;
q_lot.emplace(n - i, s);
}
vector<unsigned> weights(m);
vector<pair<unsigned, unsigned>> assigned_lot(m);
for (unsigned &x : weights)
cin >> x;
unsigned revenue = 0;
for (size_t i = 0; i < 2 * m; i++)
{
int j;
cin >> j;
if (j < 0)
{
if (!q_car.empty())
{
assigned_lot[q_car.front()] = assigned_lot[-j - 1];
revenue += weights[q_car.front()] * assigned_lot[-j - 1].second;
q_car.pop();
}
else
{
q_lot.push(assigned_lot[-j - 1]);
}
}
else
{
if (!q_lot.empty())
{
assigned_lot[j - 1] = q_lot.top();
revenue += weights[j - 1] * q_lot.top().second;
q_lot.pop();
}
else
{
q_car.push(j - 1);
}
}
}
cout << revenue << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
308 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
308 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |