# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
307325 | sofapuden | Garage (IOI09_garage) | C++14 | 4 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main(){
int n, m; cin >> n >> m;
int carpark = 0;
vector<int> v(n,0), rate(n), weight(m);
for(auto &i : rate)cin >> i;
for(auto &i : weight)cin >> i;
queue<int> overflow;
vector<int> used(m,-1);
int ans = 0;
for(int i = 0; i < 2*m; ++i){
int x; cin >> x;
if(x < 0){
if(overflow.size()){
int w = overflow.front();
overflow.pop();
ans+=weight[w]*rate[used[-x-1]];
used[w] = used[-x-1];
}
else{
v[used[-x-1]] = 0;
carpark--;
}
}
else{
if(carpark == n){
overflow.push(x-1);
}
else{
carpark++;
for(int j = 0; j < n; ++j){
if(!v[j]){
v[j] = 1;
ans+=weight[x-1]*rate[j];
used[x-1] = j;
break;
}
}
}
}
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |