結果

問題 No.2680 研究室配属
ユーザー otoshigootoshigo
提出日時 2024-03-20 21:12:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 1,363 bytes
コンパイル時間 2,829 ms
コンパイル使用メモリ 86,160 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2024-03-20 21:12:59
合計ジャッジ時間 2,616 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 3 ms
6,548 KB
testcase_05 AC 3 ms
6,548 KB
testcase_06 AC 4 ms
6,548 KB
testcase_07 AC 4 ms
6,548 KB
testcase_08 AC 4 ms
6,548 KB
testcase_09 AC 3 ms
6,548 KB
testcase_10 AC 13 ms
6,548 KB
testcase_11 AC 13 ms
6,548 KB
testcase_12 AC 17 ms
6,548 KB
testcase_13 AC 13 ms
6,548 KB
testcase_14 AC 18 ms
6,548 KB
testcase_15 AC 4 ms
6,548 KB
testcase_16 AC 38 ms
6,548 KB
testcase_17 AC 9 ms
6,548 KB
testcase_18 AC 24 ms
6,548 KB
testcase_19 AC 48 ms
6,548 KB
testcase_20 AC 40 ms
6,548 KB
testcase_21 AC 6 ms
6,548 KB
testcase_22 AC 30 ms
6,548 KB
testcase_23 AC 79 ms
7,552 KB
testcase_24 AC 78 ms
7,552 KB
testcase_25 AC 92 ms
10,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using ll=long long;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin>>N>>M;
    vector<int>A(M);
    for(int i=0;i<M;i++)cin>>A[i];
    vector T(N,vector<int>(M));
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin>>T[i][j];
        }
    }
    vector<bool>ok(N);
    vector<int>s(N);
    vector<vector<int>>V(M);
    vector<int>at(N);
    while(1){
        bool flag=true;
        for(int i=0;i<N;i++){
            if(ok[i])continue;
            ok[i]=true;
            flag=false;
            V[T[i][s[i]]].push_back(i);
        }
        if(flag)break;
        for(int i=0;i<M;i++){
            sort(all(V[i]));
            while(V[i].size()>A[i]){
                ok[V[i].back()]=false;
                s[V[i].back()]++;
                V[i].pop_back();
            }
            A[i]-=V[i].size();
            for(auto x:V[i]){
                at[x]=i;
            }
            V[i].clear();
        }
    }
    for(int i=0;i<N;i++)cout<<at[i]<<" ";
    cout<<"\n";
}
0