답안 #767890

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
767890 2023-06-27T09:07:10 Z benjaminkleyn Garage (IOI09_garage) C++17
100 / 100
2 ms 344 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n, m, r[100], w[2000];
int pos[2000];
bool open[100];

int main()
{
    cin.tie(0)->sync_with_stdio(0);

    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> r[i];
        open[i] = true;
    }
    for (int i = 0; i < m; i++)
    {
        cin >> w[i];
        pos[i] = -1;
    }

    ll ans = 0;
    queue<int> q;
    for (int t = 0, x; t < 2 * m; t++)
    {
        cin >> x;
        if (x < 0)
            open[pos[-x-1]] = true;
        else
            q.push(x-1);

        for (int i = 0, j; i < 100 && !q.empty(); i++)
            if (open[i])
            {
                j = q.front();
                q.pop();
                // cout << "car " << j + 1 << " parks in space " << i + 1 << ".\n";
                open[i] = false, pos[j] = i;
                ans += w[j] * r[i];
            }
    }
    cout << ans << '\n';
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 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 324 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 332 KB Output is correct