結果

問題 No.2680 研究室配属
ユーザー ks2mks2m
提出日時 2024-03-20 21:09:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,457 ms / 2,000 ms
コード長 1,168 bytes
コンパイル時間 2,727 ms
コンパイル使用メモリ 79,376 KB
実行使用メモリ 79,756 KB
最終ジャッジ日時 2024-03-20 21:10:17
合計ジャッジ時間 20,339 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
57,708 KB
testcase_01 AC 136 ms
57,852 KB
testcase_02 AC 147 ms
57,744 KB
testcase_03 AC 203 ms
60,512 KB
testcase_04 AC 212 ms
60,448 KB
testcase_05 AC 334 ms
62,392 KB
testcase_06 AC 335 ms
62,588 KB
testcase_07 AC 361 ms
62,544 KB
testcase_08 AC 335 ms
62,604 KB
testcase_09 AC 259 ms
61,676 KB
testcase_10 AC 644 ms
64,684 KB
testcase_11 AC 563 ms
64,404 KB
testcase_12 AC 678 ms
67,576 KB
testcase_13 AC 601 ms
64,460 KB
testcase_14 AC 708 ms
67,572 KB
testcase_15 AC 327 ms
60,732 KB
testcase_16 AC 1,081 ms
75,240 KB
testcase_17 AC 473 ms
62,744 KB
testcase_18 AC 827 ms
71,780 KB
testcase_19 AC 1,172 ms
74,696 KB
testcase_20 AC 1,064 ms
74,632 KB
testcase_21 AC 445 ms
62,668 KB
testcase_22 AC 945 ms
75,124 KB
testcase_23 AC 1,457 ms
77,464 KB
testcase_24 AC 1,396 ms
77,656 KB
testcase_25 AC 1,410 ms
79,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		for (int i = 0; i < m; i++) {
			a[i] = sc.nextInt();
		}
		int[][] t = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				t[i][j] = sc.nextInt();
			}
		}
		sc.close();

		int[] ans = new int[n];
		Arrays.fill(ans, -1);
		List<List<Integer>> list = new ArrayList<>(m);
		for (int i = 0; i < m; i++) {
			list.add(new ArrayList<>());
		}
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				if (ans[j] == -1) {
					list.get(t[j][i]).add(j);
					ans[j] = t[j][i];
				}
			}
			for (int j = 0; j < m; j++) {
				List<Integer> wk = list.get(j);
				while (wk.size() > a[j]) {
					int e = wk.remove(wk.size() - 1);
					ans[e] = -1;
				}
			}
		}

		StringBuilder sb = new StringBuilder();
		for (int i : ans) {
			sb.append(i).append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
	}
}
0