# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
515765 |
2022-01-19T15:30:54 Z |
Drew_ |
Garage (IOI09_garage) |
C++17 |
|
1 ms |
372 KB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second
#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";
using ll = long long;
using ld = long double;
using ii = pair<int, int>;
using pl = pair<ll, ll>;
ld const PI = 4*atan((ld)1);
const int MAX = 2007;
ll price[MAX];
ll car[MAX];
ll loc[MAX];
set<int> blank;
int main()
{
fastio;
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; ++i)
cin >> price[i], blank.insert(i);
for (int i = 1; i <= m; ++i)
cin >> car[i];
queue<int> q;
ll res = 0;
for (int i = 0; i < 2*m; ++i)
{
int val;
cin >> val;
if (val < 0)
{
blank.insert(loc[-val]);
if (!q.empty())
{
int tmp = q.front();
q.pop();
loc[tmp] = *blank.begin();
res += car[tmp] * price[loc[tmp]];
blank.erase(blank.begin());
}
}
else
{
if (blank.empty())
q.push(val);
else
{
loc[val] = *blank.begin();
res += car[val] * price[loc[val]];
blank.erase(blank.begin());
}
}
}
cout << res << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
316 KB |
Output is correct |
8 |
Correct |
0 ms |
320 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
320 KB |
Output is correct |
13 |
Correct |
1 ms |
320 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
372 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |