#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]];
}
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";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Runtime error |
1 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
7 |
Runtime error |
1 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
9 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
14 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
15 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
16 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
17 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
18 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
19 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
20 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |