#include "bits/stdc++.h"
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int occ[n];
memset(occ, 0, sizeof occ);
int coe[n];
for (int i=0; i<n; i++) {
cin >> coe[i];
}
int where[n];
for (int i=0; i<n; i++) {
where[i] = -1;
}
int wgt[m];
for (int i=0; i<m; i++) {
cin >> wgt[i];
}
int sm = 0;
queue<int> wait;
for (int i=0; i<2*m; i++) {
int nxt;
cin >> nxt;
bool inc = true;
if (nxt < 0) {
inc = false;
nxt = -nxt;
}
nxt--;
if (inc) {
wait.push(nxt);
}
else {
int at = where[nxt];
occ[at] = false;
}
for (int j=0; j<n && !wait.empty(); j++) {
if (!occ[j]) {
occ[j] = true;
int c = wait.front(); wait.pop();
sm += wgt[c] * coe[j];
where[c] = j;
}
}
}
cout << sm << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Incorrect |
2 ms |
252 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
424 KB |
Output isn't correct |
10 |
Runtime error |
2 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Runtime error |
2 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Runtime error |
2 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Runtime error |
2 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
15 |
Runtime error |
3 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
16 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
17 |
Runtime error |
3 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
18 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Runtime error |
3 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
20 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |