# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
74655 | 2018-09-05T15:42:38 Z | arman_ferdous | Garage (IOI09_garage) | C++17 | 4 ms | 888 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, m, r[110], w[2010], arr[110]; int main() { scanf("%d %d", &n, &m); for(int i = 1; i <= n; i++) scanf("%d", &r[i]); for(int i = 1; i <= m; i++) scanf("%d", &w[i]); ll ans = 0; int Q = m + m; queue<int> q; while(Q--) { int id; scanf("%d", &id); if(id < 0) { id = -id; for(int i = 1; i <= n; i++) if(arr[i] == id) { arr[i] = 0; if(!q.empty()) { arr[i] = q.front(); ans += 1ll * w[arr[i]] * r[i]; q.pop(); } break; } } else { for(int i = 1; i <= n; i++) if(arr[i] == 0) { arr[i] = id; id = 0; ans += 1ll * w[arr[i]] * r[i]; break; } if(id) q.push(id); } } printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 256 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 2 ms | 512 KB | Output is correct |
5 | Correct | 2 ms | 512 KB | Output is correct |
6 | Correct | 2 ms | 512 KB | Output is correct |
7 | Correct | 2 ms | 512 KB | Output is correct |
8 | Correct | 2 ms | 564 KB | Output is correct |
9 | Correct | 2 ms | 564 KB | Output is correct |
10 | Correct | 2 ms | 568 KB | Output is correct |
11 | Correct | 2 ms | 572 KB | Output is correct |
12 | Correct | 3 ms | 576 KB | Output is correct |
13 | Correct | 3 ms | 724 KB | Output is correct |
14 | Correct | 2 ms | 724 KB | Output is correct |
15 | Correct | 3 ms | 776 KB | Output is correct |
16 | Correct | 3 ms | 776 KB | Output is correct |
17 | Correct | 4 ms | 792 KB | Output is correct |
18 | Correct | 3 ms | 816 KB | Output is correct |
19 | Correct | 3 ms | 860 KB | Output is correct |
20 | Correct | 3 ms | 888 KB | Output is correct |