#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
int n,m;
cin >> n >> m;
int total = 0;
vector<int> rates(n);
vector<int> parkedposcar(n,-1);
vector<int> parkedcarpos(m,-1);
vector<int> weights(m);
set<int> available;
for (int i=0; i<n; i++) {
available.insert(i);
}
for (int i=0; i<n; i++) {
int x;
cin >> x;
rates[i] = x;
}
for (int i=0; i<m; i++) {
int x;
cin >> x;
weights[i] = x;
}
queue<int> Q;
for (int e=0; e<2*m; e++) {
//cout << "doing" <<" " << e << endl;
int x;
cin >> x;
if (x>0) {
x--;
if (!available.size()) {
Q.push(x);
}
else {
int minpos = *available.begin();
available.erase(minpos);
parkedcarpos[x] = minpos;
parkedposcar[minpos] = x;
total+=rates[minpos]*weights[x];
}
}
else {
x=-x;
x--;
assert(parkedcarpos[x]!=-1);
available.insert(parkedcarpos[x]);
parkedcarpos[x] = -1;
}
}
cout << total << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
1 ms |
376 KB |
Execution killed with signal 6 |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 6 |
7 |
Correct |
0 ms |
436 KB |
Output is correct |
8 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 6 |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Runtime error |
1 ms |
440 KB |
Execution killed with signal 6 |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Runtime error |
1 ms |
856 KB |
Execution killed with signal 6 |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 6 |
17 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 6 |
18 |
Runtime error |
2 ms |
600 KB |
Execution killed with signal 6 |
19 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 6 |
20 |
Runtime error |
2 ms |
604 KB |
Execution killed with signal 6 |