# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
53584 | ho94949 | Garage (IOI09_garage) | C++17 | 4 ms | 748 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;
int N, M;
int R[101010];
int W[101010]; //R*W
int pos[101010];
queue<int> Q;
int main()
{
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);
int ans = 0;
for(int i=0; i<2*M; ++i)
{
int t; scanf("%d", &t);
if(t>0)
Q.push(t);
else
{
for(int i=1; i<=N; ++i)
if(pos[i] == -t) pos[i] = 0;
}
for(int i=1; i<=N; ++i)
{
if(pos[i] == 0 && !Q.empty())
{
pos[i] = Q.front(); Q.pop();
ans += R[i] * W[pos[i]];
}
}
}
printf("%d\n", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |