結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

void solve() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(m), c(m, 0), ans(n, -1);
  rep(i, m) cin >> a[i];
  vector t(n, vector<ll>(m));
  rep(j, n) rep(k, m) cin >> t[j][k];
  rep(k, m) rep(j, n) {
    ll x = t[j][k];
    if (ans[j] == -1 && c[x] < a[x])
      c[x]++, ans[j] = x;
  }
  rep(i, n) cout << (i ? " " : "") << ans[i];
  cout << '\n';
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  int T = 1;
  for (int t = 0; t < T; t++) {
    solve();
  }
  return 0;
}
0