結果

問題 No.2680 研究室配属
ユーザー Today03Today03
提出日時 2024-03-20 21:38:23
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 905 bytes
コンパイル時間 1,990 ms
コンパイル使用メモリ 211,344 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2024-09-30 07:27:41
合計ジャッジ時間 4,144 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#ifdef LOCAL
#include "./debug.cpp"
#else
#define debug(...)
#define print_line
#endif
using namespace std;
using ll = long long;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i];
    }
    vector<vector<int>> T(N, vector<int>(M));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> T[i][j];
        }
    }

    queue<pair<int, int>> Q;
    vector<int> ans(N), cnt(M);
    for (int i = 0; i < N; i++) {
        Q.push({i, 0});
    }

    while (!Q.empty()) {
        auto [n, t] = Q.front();
        Q.pop();
        int h = T[n][t];
        if (cnt[h] < A[h]) {
            cnt[h]++;
            ans[n] = h;
        } else {
            Q.push({n, t + 1});
        }
    }

    for (int i = 0; i < N; i++) {
        cout << ans[i] << ' ';
    }
    cout << endl;
}
0