| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1300133 | nathlol2 | Garage (IOI09_garage) | C++20 | 2 ms | 576 KiB |
#include <bits/stdc++.h>
using namespace std;
const int N = 2222;
int n, m, ans, r[N], w[N], v[N];
queue<int> q;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
for(int i = 1;i<=n;i++) cin >> r[i];
for(int i = 1;i<=m;i++) cin >> w[i];
for(int i = 1;i<=2*m;i++){
int x;
cin >> x;
if(x > 0){
q.push(x);
while(!q.empty()){
bool f = 1;
for(int i = 1;i<=n;i++){
if(v[i] == 0){
f = 0;
v[i] = q.front();
ans += r[i] * w[v[i]];
q.pop();
break;
}
}
if(f) break;
}
}else{
for(int i = 1;i<=n;i++){
if(v[i] == -x){
v[i] = 0;
break;
}
}
while(!q.empty()){
bool f = 1;
for(int i = 1;i<=n;i++){
if(v[i] == 0){
f = 0;
v[i] = q.front();
ans += r[i] * w[v[i]];
q.pop();
break;
}
}
if(f) break;
}
}
}
cout << ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
