# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
53584 | 2018-06-30T09:04:22 Z | ho94949 | Garage (IOI09_garage) | C++17 | 4 ms | 748 KB |
#include<bits/stdc++.h> using namespace std; int N, M; int R[101010]; int W[101010]; //R*W int pos[101010]; queue<int> Q; 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); int ans = 0; for(int i=0; i<2*M; ++i) { int t; scanf("%d", &t); if(t>0) Q.push(t); else { for(int i=1; i<=N; ++i) if(pos[i] == -t) pos[i] = 0; } for(int i=1; i<=N; ++i) { if(pos[i] == 0 && !Q.empty()) { pos[i] = Q.front(); Q.pop(); ans += R[i] * W[pos[i]]; } } } printf("%d\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 484 KB | Output is correct |
3 | Correct | 2 ms | 484 KB | Output is correct |
4 | Correct | 2 ms | 484 KB | Output is correct |
5 | Correct | 2 ms | 516 KB | Output is correct |
6 | Correct | 3 ms | 516 KB | Output is correct |
7 | Correct | 2 ms | 644 KB | Output is correct |
8 | Correct | 2 ms | 644 KB | Output is correct |
9 | Correct | 2 ms | 644 KB | Output is correct |
10 | Correct | 2 ms | 748 KB | Output is correct |
11 | Correct | 2 ms | 748 KB | Output is correct |
12 | Correct | 3 ms | 748 KB | Output is correct |
13 | Correct | 2 ms | 748 KB | Output is correct |
14 | Correct | 3 ms | 748 KB | Output is correct |
15 | Correct | 3 ms | 748 KB | Output is correct |
16 | Correct | 4 ms | 748 KB | Output is correct |
17 | Correct | 3 ms | 748 KB | Output is correct |
18 | Correct | 3 ms | 748 KB | Output is correct |
19 | Correct | 3 ms | 748 KB | Output is correct |
20 | Correct | 4 ms | 748 KB | Output is correct |