# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
650748 |
2022-10-15T07:50:51 Z |
Spade1 |
Garage (IOI09_garage) |
C++14 |
|
2 ms |
344 KB |
#include<bits/stdc++.h>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;
const int N = 110, M = 2020;
int r[N], w[M];
int space[N];
queue<int> q;
void solve() {
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];
int ans = 0;
for (int i = 1; i <= 2*m; ++i) {
int j; cin >> j;
if (j > 0) {
q.push(j);
for (int i = 1; i <= n; ++i) {
if (space[i] == 0) {
space[i] = q.front();
ans += (r[i]*w[q.front()]);
q.pop();
break;
}
}
}
else {
for (int i = 1; i <= n; ++i) {
if (space[i] == -j) {
space[i] = 0;
if (!q.empty()) {
space[i] = q.front();
ans += (r[i]*w[q.front()]);
q.pop();
}
}
}
}
}
cout << ans << '\n';
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(NULL);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
324 KB |
Output is correct |
9 |
Correct |
0 ms |
324 KB |
Output is correct |
10 |
Correct |
1 ms |
324 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |