# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
869022 | HuyQuang_re_Zero | Garage (IOI09_garage) | C++14 | 2 ms | 4556 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 ll long long
#define db long double
#define N 200005
#define II pair <ll,ll>
#define III pair <ll,II>
#define IV pair <vector <int>,vector <int> >
#define fst first
#define snd second
#define BIT(x,i) ((x>>i)&1)
#define Log(x) (31-__builtin_clz((int)x))
#define LogLL(x) (63-__builtin_clzll((ll)x))
#define pi acos(-1)
#define to_radian(x) (x*pi/180.0)
#define to_degree(x) (x*180.0/pi)
using namespace std;
ll n,m,c[N],w[N],i,u,res,ok[N],pos[N];
queue <int> car;
int Find()
{
int i;
for(i=1;i<=n;i++)
if(ok[i]) break;
return i;
}
int main()
{
// freopen("garage.inp","r",stdin);
//freopen("garage.out","w",stdout);
cin>>n>>m;
for(i=1;i<=n;i++) cin>>c[i],ok[i]=1;
for(i=1;i<=m;i++) cin>>w[i];
for(i=1;i<=2*m;i++)
{
cin>>u;
if(u>0) car.push(u); else ok[pos[-u]]=1;
while(car.size()>0)
{
int u=car.front(),k=Find();
if(k>n) break;
pos[u]=k; ok[k]=0;
res+=w[u]*c[k];
car.pop();
}
}
cout<<res;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |