# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
71499 | 2018-08-24T23:15:11 Z | RezwanArefin01 | Garage (IOI09_garage) | C++17 | 6 ms | 952 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; int w[2010], r[110], pos[2010], ans; int main(int argc, char const *argv[]) { int n, m; 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]); queue<int> q; priority_queue<int, vector<int>, greater<int> > Q; for(int i = 1; i <= n; i++) Q.push(i); for(m *= 2; m--; ) { int x, y; scanf("%d", &x); if(x < 0) Q.push(pos[-x]); else q.push(x); while(!q.empty() && !Q.empty()) { x = q.front(); q.pop(); y = Q.top(); Q.pop(); ans += w[x] * r[y]; pos[x] = y; } } printf("%d\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 476 KB | Output is correct |
3 | Correct | 3 ms | 480 KB | Output is correct |
4 | Correct | 2 ms | 480 KB | Output is correct |
5 | Correct | 2 ms | 480 KB | Output is correct |
6 | Correct | 3 ms | 520 KB | Output is correct |
7 | Correct | 3 ms | 632 KB | Output is correct |
8 | Correct | 3 ms | 652 KB | Output is correct |
9 | Correct | 2 ms | 656 KB | Output is correct |
10 | Correct | 3 ms | 752 KB | Output is correct |
11 | Correct | 3 ms | 756 KB | Output is correct |
12 | Correct | 4 ms | 760 KB | Output is correct |
13 | Correct | 4 ms | 768 KB | Output is correct |
14 | Correct | 4 ms | 792 KB | Output is correct |
15 | Correct | 4 ms | 804 KB | Output is correct |
16 | Correct | 4 ms | 836 KB | Output is correct |
17 | Correct | 4 ms | 856 KB | Output is correct |
18 | Correct | 5 ms | 880 KB | Output is correct |
19 | Correct | 4 ms | 908 KB | Output is correct |
20 | Correct | 6 ms | 952 KB | Output is correct |