# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
228428 | s_avila_g | Garage (IOI09_garage) | C++14 | 320 ms | 444 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
queue<int> col;
map<int,int> mp;
int main(){
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
int n,m;
cin>>n>>m;
vector<int> parks(n);
vector<int> cars(n);
for(int i = 0 ; i < n; i++)cin>>parks[i];
for(int i = 0 ; i < m; i++)cin>>cars[i];
int vis[n];
memset(vis,0,sizeof vis);
int ans = 0;
for(int i = 0 ; i < (2*m); i++){
int x;
cin>>x;
bool libre = false;
if(x > 0){
int pos;
for(int j = 0; j < n; j++){
if(vis[j] == 0){
libre = true;
pos = j;
break;
}
}
if(!libre){
col.push(x);
}else{
mp[x] = pos;
ans += cars[x-1] * parks[pos];
vis[pos] = 1;
}
}else{
vis[mp[abs(x)]] = 0;
if(!col.empty()){
int nxt = col.front();
vis[mp[abs(x)]] = 1;
col.pop();
ans += cars[nxt-1] * parks[mp[abs(x)]];
}
mp[abs(x)] = -1;
}
}
cout<<ans<<endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |