# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
495434 | ToroTN | Garage (IOI09_garage) | C++14 | 2 ms | 336 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,hsh[105],w[2005],r[105],car,cnt=0,u,type;
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]);
}
for(int i=1;i<=2*m;i++)
{
scanf("%d",&car);
if(car>0)
{
q.push(car);
}else
{
for(int j=1;j<=n;j++)
{
if(hsh[j]==-car)
{
hsh[j]=0;
}
}
}
while(!q.empty())
{
u=q.front();
type=-1;
for(int j=1;j<=n;j++)
{
if(hsh[j]==0)
{
type=0;
hsh[j]=u;
cnt+=r[j]*w[u];
break;
}
}
if(type==-1)
{
break;
}
q.pop();
}
//printf("%d\n",cnt);
}
printf("%d\n",cnt);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |