# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
767890 | benjaminkleyn | Garage (IOI09_garage) | C++17 | 2 ms | 344 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, r[100], w[2000];
int pos[2000];
bool open[100];
int main()
{
cin.tie(0)->sync_with_stdio(0);
cin >> n >> m;
for (int i = 0; i < n; i++)
{
cin >> r[i];
open[i] = true;
}
for (int i = 0; i < m; i++)
{
cin >> w[i];
pos[i] = -1;
}
ll ans = 0;
queue<int> q;
for (int t = 0, x; t < 2 * m; t++)
{
cin >> x;
if (x < 0)
open[pos[-x-1]] = true;
else
q.push(x-1);
for (int i = 0, j; i < 100 && !q.empty(); i++)
if (open[i])
{
j = q.front();
q.pop();
// cout << "car " << j + 1 << " parks in space " << i + 1 << ".\n";
open[i] = false, pos[j] = i;
ans += w[j] * r[i];
}
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |