# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
71499 | RezwanArefin01 | Garage (IOI09_garage) | C++17 | 6 ms | 952 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;
typedef pair<int, int> ii;
int w[2010], r[110], pos[2010], ans;
int main(int argc, char const *argv[]) {
int n, m;
scanf("%d %d", &n, &m);
for(int i = 1; i <= n; i++)
scanf("%d", &r[i]);
for(int i = 1; i <= m; i++)
scanf("%d", &w[i]);
queue<int> q;
priority_queue<int, vector<int>, greater<int> > Q;
for(int i = 1; i <= n; i++) Q.push(i);
for(m *= 2; m--; ) {
int x, y; scanf("%d", &x);
if(x < 0) Q.push(pos[-x]);
else q.push(x);
while(!q.empty() && !Q.empty()) {
x = q.front(); q.pop();
y = Q.top(); Q.pop();
ans += w[x] * r[y];
pos[x] = y;
}
}
printf("%d\n", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |