結果

問題 No.2680 研究室配属
ユーザー tnakao0123
提出日時 2024-04-26 14:11:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 776 bytes
コンパイル時間 344 ms
コンパイル使用メモリ 42,112 KB
実行使用メモリ 7,120 KB
最終ジャッジ日時 2024-11-14 02:35:44
合計ジャッジ時間 3,100 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2680.cc:  No.2680 研究室配属 - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 1000;
const int MAX_M = 1000;

/* typedef */

/* global variables */

int as[MAX_M], ts[MAX_N][MAX_M], ls[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int j = 0; j < m; j++) scanf("%d", as + j);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", ts[i] + j);

  fill(ls, ls + n, -1);
  for (int j = 0; j < m; j++) {
    for (int i = 0; i < n; i++)
      if (ls[i] < 0 && as[ts[i][j]])
	ls[i] = ts[i][j], as[ts[i][j]]--;
  }

  for (int i = 0; i < n; i++)
    printf("%d%c", ls[i], (i + 1 < n) ? ' ' : '\n');
  
  return 0;
}
0