Submission #869022

#TimeUsernameProblemLanguageResultExecution timeMemory
869022HuyQuang_re_ZeroGarage (IOI09_garage)C++14
100 / 100
2 ms4556 KiB
#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 timeMemoryGrader output
Fetching results...