結果

問題 No.710 チーム戦
ユーザー 37zigen37zigen
提出日時 2018-06-29 20:32:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 247 ms / 3,000 ms
コード長 1,216 bytes
コンパイル時間 2,013 ms
コンパイル使用メモリ 75,528 KB
実行使用メモリ 111,604 KB
最終ジャッジ日時 2023-09-13 15:18:21
合計ジャッジ時間 9,322 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 151 ms
58,124 KB
testcase_01 AC 152 ms
57,552 KB
testcase_02 AC 242 ms
111,296 KB
testcase_03 AC 242 ms
111,432 KB
testcase_04 AC 246 ms
111,212 KB
testcase_05 AC 238 ms
111,324 KB
testcase_06 AC 236 ms
111,604 KB
testcase_07 AC 233 ms
111,384 KB
testcase_08 AC 238 ms
111,384 KB
testcase_09 AC 240 ms
111,004 KB
testcase_10 AC 241 ms
111,464 KB
testcase_11 AC 242 ms
111,304 KB
testcase_12 AC 244 ms
111,032 KB
testcase_13 AC 247 ms
111,308 KB
testcase_14 AC 243 ms
111,516 KB
testcase_15 AC 240 ms
111,300 KB
testcase_16 AC 240 ms
111,440 KB
testcase_17 AC 239 ms
111,264 KB
testcase_18 AC 234 ms
111,456 KB
testcase_19 AC 233 ms
111,432 KB
testcase_20 AC 233 ms
111,292 KB
testcase_21 AC 234 ms
111,320 KB
testcase_22 AC 228 ms
111,400 KB
testcase_23 AC 228 ms
111,304 KB
testcase_24 AC 232 ms
111,200 KB
testcase_25 AC 145 ms
55,764 KB
testcase_26 AC 146 ms
55,716 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();
		if (!(1 <= N && N <= 100))
			throw new AssertionError();
		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();
			if (!(1 <= A && A <= 1000) || !(1 <= B && B <= 1000))
				throw new AssertionError();
			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