# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
733919 | 2023-05-01T11:59:11 Z | vjudge1 | Garage (IOI09_garage) | C++17 | 2 ms | 212 KB |
#include<bits/stdc++.h> using namespace std; using ll = long long; int main() { int t, n, m, ans, i, z,j, x, r, p, s, y; cin >> n >> m; ll a[n + 2], b[m + 2], c[m + 2]; ans = 0; priority_queue < ll , vector < ll > , greater< ll >> pq; for ( i = 1; i <= n; i ++) { cin >> a[i]; pq.push(i); } for ( i = 1; i <= m; i ++) { cin >> b[i]; } queue < ll > q; for ( i = 1; i <= 2 * m; i ++) { cin >> x; if ( x < 0) { r = -x; pq.push(c[r]); } else { if ( pq.empty()) { q.push(x); continue; } p = pq.top(); pq.pop(); c[x] = p; ans += (a[p] * b[x]); } if ( !pq.empty() && !q.empty()) { x = q.front(); q.pop(); p = pq.top(); pq.pop(); c[x] = p; ans += (a[p] * b[x]); } } cout << ans << endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 2 ms | 212 KB | Output is correct |
17 | Correct | 2 ms | 212 KB | Output is correct |
18 | Correct | 2 ms | 212 KB | Output is correct |
19 | Correct | 2 ms | 212 KB | Output is correct |
20 | Correct | 2 ms | 212 KB | Output is correct |