# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
292004 | NicolaAbusaad2014 | Garage (IOI09_garage) | C++14 | 2 ms | 512 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 main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n,m,x,ans=0;
cin>>n>>m;
long arr[n],weight[m],used[m]= {};
bool N_A[n]= {};
for(long i=0; i<n; i++)
{
cin>>arr[i];
}
for(long i=0; i<m; i++)
{
cin>>weight[i];
}
queue<long>q;
for(long i=0; i<2*m; i++)
{
cin>>x;
if(x>0)
{
q.push(x);
}
else
{
N_A[used[-x-1]]=false;
}
if(!q.empty())
{
for(long j=0; j<n; j++)
{
if(!N_A[j])
{
N_A[j]=true;
x=q.front();
used[x-1]=j;
ans+=(weight[x-1]*arr[j]);
q.pop();
break;
}
}
}
}
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |