# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
235317 | Pbezz | Garage (IOI09_garage) | C++14 | 7 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 <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 10000000
#define MAXN 100005
typedef pair<int, int> pii;
int main(){
ll int n,m,k,i,j,ans=0;
cin>>n>>m;
vector<ll int>cost(n);
vector<ll int>weight(m);
for(i=0;i<n;i++){
cin>>cost[i];
}
for(i=0;i<m;i++){
cin>>weight[i];
}
queue<ll int>q;
int location[m];//localização do carro i
int occupied[n];//que carro está em i
memset(location, -1, sizeof(location) );
memset(occupied, -1, sizeof(occupied) );
for(j=0;j<2*m;j++){
cin>>k;
if(k>0){k--;
q.push(k);
}else{k++;
occupied[location[-k]]=-1;
location[-k]=-1;
}
i=0;
while(!q.empty() && i<n){
while(i<n && occupied[i]!=-1)i++;
if(i==n)continue;
k=q.front(); q.pop();
occupied[i]=k;
location[k]=i;
ans+=weight[k]*cost[i];
}
//cout<<k<<" "<<ans<<endl;
}
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |