# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
423284 |
2021-06-10T22:04:00 Z |
haxorman |
Garage (IOI09_garage) |
C++14 |
|
3 ms |
332 KB |
#include <bits/stdc++.h>
using namespace std;
const int mxN = 107;
const int mxM = 2007;
bool arr[mxN];
int r[mxN], w[mxM], pos[mxM];
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
cin >> r[i];
}
for (int i = 1; i <= m; ++i) {
cin >> w[i];
}
long long ans = 0;
queue<int> q;
for (int iter = 1; iter <= 2 * m; ++iter) {
int car;
cin >> car;
if (car < 0) {
car = -car;
arr[pos[car]] = false;
for (int i = 1; i <= n && q.size(); ++i) {
if (!arr[i]) {
cout << q.front() << ' ' << i << "\n";
arr[i] = true;
ans += r[i] * w[q.front()];
pos[q.front()] = i;
q.pop();
}
}
}
else {
q.push(car);
for (int i = 1; i <= n && q.size(); ++i) {
if (!arr[i]) {
//cout << q.front() << ' ' << i << "\n";
arr[i] = true;
ans += r[i] * w[q.front()];
pos[q.front()] = i;
q.pop();
}
}
}
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
17 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
18 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
19 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
20 |
Incorrect |
2 ms |
204 KB |
Output isn't correct |