結果

問題 No.2680 研究室配属
ユーザー yansi819yansi819
提出日時 2024-03-23 11:16:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 1,203 bytes
コンパイル時間 4,713 ms
コンパイル使用メモリ 263,984 KB
実行使用メモリ 10,172 KB
最終ジャッジ日時 2024-03-23 11:17:05
合計ジャッジ時間 8,749 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 7 ms
6,676 KB
testcase_06 AC 8 ms
6,676 KB
testcase_07 AC 8 ms
6,676 KB
testcase_08 AC 7 ms
6,676 KB
testcase_09 AC 5 ms
6,676 KB
testcase_10 AC 31 ms
6,676 KB
testcase_11 AC 30 ms
6,676 KB
testcase_12 AC 41 ms
6,676 KB
testcase_13 AC 30 ms
6,676 KB
testcase_14 AC 44 ms
6,676 KB
testcase_15 AC 8 ms
6,676 KB
testcase_16 AC 97 ms
6,676 KB
testcase_17 AC 19 ms
6,676 KB
testcase_18 AC 59 ms
6,844 KB
testcase_19 AC 127 ms
6,972 KB
testcase_20 AC 103 ms
7,228 KB
testcase_21 AC 13 ms
7,356 KB
testcase_22 AC 77 ms
7,612 KB
testcase_23 AC 210 ms
7,612 KB
testcase_24 AC 209 ms
7,612 KB
testcase_25 AC 245 ms
10,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int N, M, A[1010], T[1010][1010], ans[1010];
priority_queue<int, vector<int>, less<int>> pq[1010];
bool flag[1010];

int main() {
  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 i = 0; i < M; i++) {
    for (int j = 0; j < N; j++) {
      if (!flag[j]) {
        pq[T[j][i]].push(j);
        flag[j] = true;
      }
    }
    for (int j = 0; j < M; j++) {
      if (pq[j].size() > A[j]) {
        while (pq[j].size() > A[j]) {
          int k = pq[j].top(); pq[j].pop();
          flag[k] = false;
          //cout << j << ' ' << k << endl;
        }
      }
      A[j] -= pq[j].size();
      while (!pq[j].empty()) {
        int k = pq[j].top(); pq[j].pop();
        ans[k] = j;
      }
    }
    bool flag1 = true;
    for (int j = 0; j < N; j++) {
      if (!flag[j]) {
        flag1 = false;
        break;
      }
    }
    if (flag1) break;
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << " \n"[i == N - 1];
  }
  return 0;
}
0