#include <bits/stdc++.h>
using namespace std;
int main(){
int n, m; cin >> n >> m;
int rates[n]; for(int i = 0; i < n; i++) cin >> rates[i];
int weights[m]; for(int i = 0; i < m; i++) cin >> weights[i];
vector<bool> status(n, true);
vector<int> in(n, -1);
int empty = 0, ans = 0;
for(int i = 0; i < 2 * m; i++){
int x; cin >> x;
if(x > 0){
ans += rates[empty] * weights[x - 1]; status[empty] = false; in[x - 1] = empty;
for(int i = 0; i < n; i++){
if(status[i]) {empty = i; break;}
}
}else{
status[in[abs(x) - 1]] = true; empty = min(empty, in[abs(x - 1)]);
}
}
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
2 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
5 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
6 |
Runtime error |
1 ms |
424 KB |
Execution killed with signal 6 |
7 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
8 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
9 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
10 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
11 |
Runtime error |
1 ms |
304 KB |
Execution killed with signal 11 |
12 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
13 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
14 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
15 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
16 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
17 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
18 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
19 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 6 |
20 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |