# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
287380 | Namnamseo | Garage (IOI09_garage) | C++17 | 2 ms | 384 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 <cstdio>
#include <cstdlib>
int sc[2010];
int ww[2010];
int place[2010];
int who [2010];
int n,m;
int queue[2010];
int h,t;
int main()
{
int income=0;
scanf("%d%d",&n,&m);
for(int i=1; i<=n; ++i) scanf("%d",sc+i);
for(int i=1; i<=m; ++i) scanf("%d",ww+i);
int a;
int filled=0;
for(int _=1; _<=2*m; ++_){
scanf("%d",&a);
if(a>0){
queue[h++]=a;
} else {
a=-a;
who[place[a]]=0;
place[a]=0;
--filled;
}
while(filled<n && t<h){
int i;
for(i=1; i<=n; ++i){
if(who[i]==0) break;
}
who[i]=queue[t];
place[queue[t]]=i;
income += sc[i]*ww[who[i]];
++filled; ++t;
}
}
printf("%d\n",income);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |