답안 #921540

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921540 2024-02-04T06:07:55 Z josanneo22 Garage (IOI09_garage) C++17
100 / 100
1 ms 360 KB
#pragma warning(suppress : 4996)
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

#define L(i,j,k) for(int i=(j);i<=(k);++i)
#define R(i,j,k) for(int i=(j);i>=(k);--i)
#define all(x) x.begin(),x.end()
#define me(x,a) memset(x,a,sizeof(x))


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int N, M; cin >> N >> M;
    vector<int> r(N); L(i, 0, N - 1) cin >> r[i];
    vector<int> w(M); L(i, 0, M - 1) cin >> w[i];
    vector<int> meow(M + 1, -1);
    i64 ans = 0;
    set<int> S;  L(i, 0, N - 1) S.insert(i);
    queue<int> Q;
    L(i, 0, 2 * M - 1) {
        int x; cin >> x;
        if (x > 0) {
            x--;
            Q.push(x);
        }
        else {
            x = -x;
            x--;
            ans += r[meow[x]] * w[x];
            S.insert(meow[x]);
            meow[x] = -1;
        }

        if (Q.size() && S.size()) {
            int nw = Q.front(); Q.pop();
            int pos = *S.begin();
            meow[nw] = pos;
            S.erase(S.begin());
        }
    }
    cout << ans << '\n';
}

Compilation message

garage.cpp:1: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
    1 | #pragma warning(suppress : 4996)
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 360 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct