結果

問題 No.393 2本の竹
ユーザー 37zigen37zigen
提出日時 2016-07-03 20:15:13
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,001 bytes
コンパイル時間 2,490 ms
コンパイル使用メモリ 78,384 KB
実行使用メモリ 57,664 KB
最終ジャッジ日時 2024-04-23 01:45:14
合計ジャッジ時間 8,224 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 167 ms
45,808 KB
testcase_01 AC 152 ms
45,208 KB
testcase_02 AC 158 ms
45,980 KB
testcase_03 AC 161 ms
45,816 KB
testcase_04 AC 148 ms
45,940 KB
testcase_05 AC 161 ms
46,204 KB
testcase_06 AC 155 ms
45,636 KB
testcase_07 AC 180 ms
45,732 KB
testcase_08 AC 208 ms
46,080 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 210 ms
46,192 KB
testcase_14 AC 189 ms
46,196 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 163 ms
45,956 KB
testcase_18 AC 155 ms
46,084 KB
testcase_19 AC 141 ms
45,144 KB
testcase_20 AC 155 ms
45,552 KB
testcase_21 AC 165 ms
45,804 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 AC 179 ms
46,052 KB
testcase_25 AC 158 ms
46,000 KB
testcase_26 AC 147 ms
45,020 KB
testcase_27 RE -
権限があれば一括ダウンロードができます

ソースコード

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 <= len; 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