結果

問題 No.2680 研究室配属
ユーザー kokosei
提出日時 2024-03-20 22:30:27
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 2,753 ms
コンパイル使用メモリ 245,220 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2024-09-30 08:28:50
合計ジャッジ時間 4,599 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int N, M;
int A[1010], T[1010][1010];
bool used[1010];
int ans[1010];
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> N >> 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 j = 0;j < M;j++){
        for(int i = 0;i < N;i++)if(!used[i]){
            if(A[T[i][j]] == 0)continue;
            A[T[i][j]]--;
            used[i] = true;
            ans[i] = T[i][j];
        }
    }
    for(int i = 0;i < N;i++){
        cout << ans[i] << " \n"[i + 1 == N];
    }
    return 0;
}
0