結果

問題 No.393 2本の竹
ユーザー 37zigen37zigen
提出日時 2016-07-03 20:38:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 281 ms / 1,000 ms
コード長 1,003 bytes
コンパイル時間 2,243 ms
コンパイル使用メモリ 73,980 KB
実行使用メモリ 59,904 KB
最終ジャッジ日時 2023-08-07 23:56:32
合計ジャッジ時間 9,702 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 168 ms
59,012 KB
testcase_01 AC 133 ms
59,092 KB
testcase_02 AC 144 ms
58,516 KB
testcase_03 AC 146 ms
58,808 KB
testcase_04 AC 137 ms
58,704 KB
testcase_05 AC 141 ms
58,792 KB
testcase_06 AC 138 ms
58,972 KB
testcase_07 AC 156 ms
58,204 KB
testcase_08 AC 180 ms
58,660 KB
testcase_09 AC 281 ms
59,408 KB
testcase_10 AC 206 ms
59,132 KB
testcase_11 AC 232 ms
58,976 KB
testcase_12 AC 242 ms
58,968 KB
testcase_13 AC 219 ms
59,304 KB
testcase_14 AC 177 ms
58,872 KB
testcase_15 AC 164 ms
58,480 KB
testcase_16 AC 170 ms
58,960 KB
testcase_17 AC 146 ms
58,380 KB
testcase_18 AC 141 ms
58,548 KB
testcase_19 AC 130 ms
58,696 KB
testcase_20 AC 138 ms
58,428 KB
testcase_21 AC 143 ms
59,048 KB
testcase_22 AC 196 ms
59,556 KB
testcase_23 AC 190 ms
56,688 KB
testcase_24 AC 164 ms
58,896 KB
testcase_25 AC 160 ms
58,916 KB
testcase_26 AC 132 ms
58,204 KB
testcase_27 AC 263 ms
59,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static Scanner sc=new Scanner(System.in);

	public static void main(String[] args) {
		int d = sc.nextInt();
		for(;d>0;d--){
			new Main().solver();
		}
	}

	void solver() {
		int n1 = sc.nextInt();
		int n2 = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		for (int i = 0; i < m; i++) {
			a[i] = sc.nextInt();

		}
		
		Arrays.sort(a);
		

		boolean[] from = new boolean[n1 + 1];
		from[0] = true;
		int len = 0;
		for (int i = 0; i < m; i++) {
			boolean[] to = new boolean[100001];
			boolean f=false;
			for (int j = 0; j <= n1; j++) {
				if (from[j]) {
					if (j + a[i] <= n1) {
						to[j + a[i]] = true;
						f=true;
					}
					if ((len - j) + a[i] <= n2) {
						to[j] = true;
						f=true;
					}
				}
			}

			len+=a[i];
			from=to;

			if(!f){
				System.out.println(i);
				return;
			}
		}
		System.out.println(m);
	}
	
	void tr(Object...o){System.out.println(Arrays.deepToString(o));}
}
0