結果

問題 No.710 チーム戦
ユーザー htensaihtensai
提出日時 2020-01-30 14:23:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,495 ms / 3,000 ms
コード長 1,402 bytes
コンパイル時間 2,346 ms
コンパイル使用メモリ 75,816 KB
実行使用メモリ 83,480 KB
最終ジャッジ日時 2023-10-14 08:26:20
合計ジャッジ時間 29,166 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,488 KB
testcase_01 AC 44 ms
49,380 KB
testcase_02 AC 1,076 ms
71,720 KB
testcase_03 AC 1,100 ms
72,412 KB
testcase_04 AC 1,258 ms
72,812 KB
testcase_05 AC 1,045 ms
71,476 KB
testcase_06 AC 995 ms
70,728 KB
testcase_07 AC 1,304 ms
75,872 KB
testcase_08 AC 1,045 ms
76,144 KB
testcase_09 AC 1,120 ms
74,916 KB
testcase_10 AC 939 ms
73,572 KB
testcase_11 AC 1,157 ms
73,504 KB
testcase_12 AC 1,319 ms
75,072 KB
testcase_13 AC 1,135 ms
75,636 KB
testcase_14 AC 1,188 ms
74,764 KB
testcase_15 AC 1,117 ms
72,840 KB
testcase_16 AC 1,133 ms
77,732 KB
testcase_17 AC 883 ms
70,840 KB
testcase_18 AC 1,121 ms
72,116 KB
testcase_19 AC 1,217 ms
76,244 KB
testcase_20 AC 1,141 ms
72,776 KB
testcase_21 AC 984 ms
75,000 KB
testcase_22 AC 85 ms
51,944 KB
testcase_23 AC 76 ms
51,896 KB
testcase_24 AC 1,495 ms
83,480 KB
testcase_25 AC 42 ms
49,364 KB
testcase_26 AC 44 ms
49,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    static int[][] scores;
    static int[][] dp;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        HashMap<Integer, Integer> map = new HashMap<>();
        HashMap<Integer, Integer> next = new HashMap<>();
        map.put(0, 0);
        for (int i = 0; i < n; i++) {
            String[] line = br.readLine().split(" ", 2);
            int a = Integer.parseInt(line[0]);
            int b = Integer.parseInt(line[1]);
            for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
                int key = entry.getKey();
                int value = entry.getValue();
                if (!next.containsKey(key) || next.get(key) >= value + b) {
                    next.put(key, value + b);
                }
                key += a;
                if (!next.containsKey(key) || next.get(key) >= value) {
                    next.put(key, value);
                }
            }
            map = next;
            next = new HashMap<>();
        }
        int min = Integer.MAX_VALUE;
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            min = Math.min(min, Math.max(entry.getKey(), entry.getValue()));
        }
        System.out.println(min);
    }
}
0