結果

問題 No.710 チーム戦
ユーザー 37zigen37zigen
提出日時 2018-06-29 20:30:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 237 ms / 3,000 ms
コード長 1,067 bytes
コンパイル時間 2,397 ms
コンパイル使用メモリ 74,120 KB
実行使用メモリ 113,328 KB
最終ジャッジ日時 2023-09-13 15:17:58
合計ジャッジ時間 9,353 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
57,800 KB
testcase_01 AC 144 ms
58,020 KB
testcase_02 AC 222 ms
111,368 KB
testcase_03 AC 226 ms
110,992 KB
testcase_04 AC 226 ms
111,120 KB
testcase_05 AC 232 ms
109,204 KB
testcase_06 AC 228 ms
111,140 KB
testcase_07 AC 233 ms
110,996 KB
testcase_08 AC 234 ms
111,812 KB
testcase_09 AC 236 ms
110,928 KB
testcase_10 AC 229 ms
113,328 KB
testcase_11 AC 233 ms
111,444 KB
testcase_12 AC 225 ms
111,124 KB
testcase_13 AC 229 ms
111,076 KB
testcase_14 AC 228 ms
111,012 KB
testcase_15 AC 227 ms
111,256 KB
testcase_16 AC 230 ms
111,188 KB
testcase_17 AC 233 ms
110,828 KB
testcase_18 AC 233 ms
110,976 KB
testcase_19 AC 231 ms
110,844 KB
testcase_20 AC 232 ms
111,252 KB
testcase_21 AC 232 ms
111,752 KB
testcase_22 AC 224 ms
111,192 KB
testcase_23 AC 218 ms
111,348 KB
testcase_24 AC 237 ms
111,364 KB
testcase_25 AC 146 ms
55,560 KB
testcase_26 AC 152 ms
55,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.FileNotFoundException;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] ok = new int[N + 1][100000 + 1];
		for (int i = 0; i < ok.length; ++i) {
			for (int j = 0; j < ok[i].length; ++j) {
				ok[i][j] = Integer.MAX_VALUE / 3;
			}
		}
		ok[0][0] = 0;
		for (int i = 0; i < N; ++i) {
			int A = sc.nextInt();
			int B = sc.nextInt();
			for (int j = 0; j < ok[i].length; ++j) {
				if (ok[i][j] == Integer.MAX_VALUE / 3)
					continue;
				ok[i + 1][j + A] = Math.min(ok[i + 1][j + A], ok[i][j]);
				ok[i + 1][j] = Math.min(ok[i + 1][j], ok[i][j] + B);
			}
		}
		int ans = Integer.MAX_VALUE / 3;
		for (int i = 0; i < ok[N].length; ++i) {
			ans = Math.min(ans, Math.max(i, ok[N][i]));
		}
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}
0