# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
372559 | meperdonas203 | Garage (IOI09_garage) | C++17 | 1 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 n,m;
int rates[102];
int weights[2002];
int estacionamiento[102];
queue<int> fila;
int ans,num;
int busca_esp(int x){
for(int i=1;i<=n;i++){
if(estacionamiento[i]==x){
return i;
}
}
return -1;
}
void colocar(int carro, int espacio){
estacionamiento[espacio]=carro;
ans+=rates[espacio]*weights[carro];
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>rates[i];
}
for(int i=1;i<=m;i++){
cin>>weights[i];
}
for(int i=1;i<=2*m;i++){
cin>>num;
if(num<0){
//sacas carro
int espacio=busca_esp(num*-1);
estacionamiento[espacio]=0;
if(!fila.empty()){
colocar(fila.front(),espacio);
fila.pop();
}
}else{
//metes carro, sino hay lugar lo metes en la fila
int espacio=busca_esp(0);
if(espacio==-1){
fila.push(num);
}else{
colocar(num,espacio);
}
}
}
cout<<ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |