# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
311619 | 2020-10-10T19:23:27 Z | ipaljak | Garage (IOI09_garage) | C++14 | 2 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 105; const int MAXM = 2010; int n, m; int r[MAXN], w[MAXM], park[MAXM]; set<int> sp; int main(void) { scanf("%d%d", &n, &m); for (int i = 0; i < n; ++i) scanf("%d", &r[i]); for (int i = 0; i < m; ++i) scanf("%d", &w[i]); for (int i = 0; i < n; ++i) sp.insert(i); queue<int> q; int sol = 0; for (int i = 0; i < 2 * m; ++i) { int x; scanf("%d", &x); if (x > 0) { --x; if (sp.empty()) { q.push(x); continue; } sol += r[*sp.begin()] * w[x]; park[x] = *sp.begin(); sp.erase(sp.begin()); } else { x = abs(x); --x; sp.insert(park[x]); if (!q.empty()) { int x = q.front(); q.pop(); sol += r[*sp.begin()] * w[x]; park[x] = *sp.begin(); sp.erase(sp.begin()); } } } printf("%d\n", sol); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |