# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
151331 | GioChkhaidze | Garage (IOI09_garage) | C++14 | 5 ms | 416 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>
#define F first
#define S second
using namespace std;
const int N=104;
const int M=2004;
long long n,m,Cars;
long long R[N],W[M],Id[M];
long long ANS;
bool F[N];
queue < int > q;
main () {
cin>>n>>m;
for (int i=1; i<=n; i++)
cin>>R[i];
for (int i=1; i<=m; i++)
cin>>W[i];
for (int i=1; i<=2*m; i++) {
int idx=0;
cin>>idx;
if (idx<0) idx=-idx,Cars--,F[Id[idx]]=0;
else q.push(idx);
while (q.size() && n>Cars) {
int ID=q.front();
q.pop();
for (int j=1; j<=n; j++)
if (!F[j]) {
Cars++,F[j]=1,Id[ID]=j;
ANS+=R[j]*W[ID];
break;
}
}
}
cout<<ANS<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |