結果

問題 No.2680 研究室配属
ユーザー srjywrdnprkt
提出日時 2024-03-29 10:27:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 660 bytes
コンパイル時間 2,287 ms
コンパイル使用メモリ 198,236 KB
最終ジャッジ日時 2025-02-20 14:25:55
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

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

    for (int i=0; i<M; i++){
        for (int j=0; j<N; j++){
            if (A[T[j][i]] > 0 && ans[j] == -1){
                ans[j] = T[j][i];
                A[T[j][i]]--;
            }
        }
    }

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

    return 0;
}
0