# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
227949 | kimbj0709 | Garage (IOI09_garage) | C++14 | 5 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;
#define int long long
#define maxn 2050
int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int no_of_space,no_of_car;
int input1,input2;
priority_queue<int,vector<int>,greater<int> > q1;
cin >> no_of_space >> no_of_car;
vector<int> price(maxn);
vector<int> weight(maxn);
for(int i=1;i<=no_of_space;i++){
q1.push(i);
cin >> input1;
price[i] = input1;
}
for(int i=1;i<=no_of_car;i++){
cin >> input1;
weight[i] = input1;
}
int ans = 0;
vector<int> taken(maxn,0);
deque<int> q2;
for(int i=0;i<2*no_of_car;i++){
cin >> input1;
if(input1>0){//enter
q2.push_back(input1);
}
else{
input1 *= -1;
q1.push(taken[input1]);
taken[input1] = 0;
}
while(q1.size()!=0&&q2.size()!=0){
ans += weight[q2.front()]*price[q1.top()];
taken[q2.front()] = q1.top();
q1.pop();q2.pop_front();
}
}
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |