結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

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

    int N,M; cin >> N >> M;
    vector<int> A(M);
    for(auto &a : A) cin >> a;
    vector<vector<int>> T(N,vector<int>(M));
    for(int i=0; i<N; i++) for(int k=0; k<M; k++) cin >> T.at(i).at(k);

    vector<int> answer(N,-1);
    vector<int> now(M);
    for(int i=0; i<M; i++){
        vector<queue<int>> Q(M);
        for(int k=0; k<N; k++){
            if(answer.at(k) != -1) continue;
            Q.at(T.at(k).at(i)).push(k);
        }
        for(int k=0; k<M; k++){
            while(now.at(k) < A.at(k) && Q.at(k).size()){
                int pos = Q.at(k).front(); Q.at(k).pop();
                answer.at(pos) = k; now.at(k)++;
            }
        }
    }
    
    for(int i=0; i<N; i++){
        if(i) cout << " ";
        cout << answer.at(i);
    }
    cout << endl;
}
0