結果

問題 No.2680 研究室配属
ユーザー tentententen
提出日時 2024-03-25 09:25:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 493 ms / 2,000 ms
コード長 2,015 bytes
コンパイル時間 2,583 ms
コンパイル使用メモリ 87,724 KB
実行使用メモリ 66,668 KB
最終ジャッジ日時 2024-03-25 09:26:13
合計ジャッジ時間 9,956 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
54,616 KB
testcase_01 AC 69 ms
54,640 KB
testcase_02 AC 71 ms
54,752 KB
testcase_03 AC 88 ms
55,280 KB
testcase_04 AC 92 ms
55,520 KB
testcase_05 AC 166 ms
55,160 KB
testcase_06 AC 155 ms
57,452 KB
testcase_07 AC 153 ms
57,324 KB
testcase_08 AC 150 ms
57,312 KB
testcase_09 AC 138 ms
55,612 KB
testcase_10 AC 221 ms
61,880 KB
testcase_11 AC 222 ms
61,944 KB
testcase_12 AC 239 ms
61,904 KB
testcase_13 AC 221 ms
61,804 KB
testcase_14 AC 245 ms
59,852 KB
testcase_15 AC 153 ms
59,756 KB
testcase_16 AC 356 ms
64,360 KB
testcase_17 AC 187 ms
60,980 KB
testcase_18 AC 273 ms
61,944 KB
testcase_19 AC 400 ms
64,612 KB
testcase_20 AC 364 ms
64,360 KB
testcase_21 AC 169 ms
60,016 KB
testcase_22 AC 302 ms
60,068 KB
testcase_23 AC 454 ms
66,420 KB
testcase_24 AC 456 ms
66,668 KB
testcase_25 AC 493 ms
66,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] counts = new int[m];
        for (int i = 0; i < m; i++) {
            counts[i] = sc.nextInt();
        }
        int[][] selected = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                selected[i][j] = sc.nextInt();
            }
        }
        boolean[] decided = new boolean[n];
        int[] ans = new int[n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (decided[j]) {
                    continue;
                }
                if (counts[selected[j][i]] > 0) {
                    counts[selected[j][i]]--;
                    decided[j] = true;
                    ans[j] = selected[j][i];
                }
            }
        }
        System.out.println(Arrays.stream(ans).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}
0