# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
697750 | hiikunZ | Garage (IOI09_garage) | C++17 | 2 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
int main(){
ll N,M;
cin >> N >> M;
vector<ll> R(N),W(M),U(N,0),P(M,-1);
ll ans = 0;
for(ll i = 0;i < N;i++) cin >> R[i];
for(ll i = 0;i < M;i++) cin >> W[i];
queue<ll> que;
for(ll q = 0;q < M * 2;q++){
ll s;
cin >> s;
if(s > 0){
s--;
que.emplace(s);
}
else{
s *= -1;
s--;
U[P[s]] = 0;
}
while(!que.empty()){
ll ok = 0;
for(ll i = 0;i < N;i++){
if(U[i] == 0){
U[i] = 1;
P[que.front()] = i;
ans += R[i] * W[que.front()];
que.pop();
ok = 1;
break;
}
}
if(!ok) break;
}
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |