結果
問題 | No.393 2本の竹 |
ユーザー | 37zigen |
提出日時 | 2016-07-03 20:51:03 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 155 ms / 1,000 ms |
コード長 | 2,094 bytes |
コンパイル時間 | 2,176 ms |
コンパイル使用メモリ | 74,768 KB |
実行使用メモリ | 56,284 KB |
最終ジャッジ日時 | 2023-08-07 23:56:57 |
合計ジャッジ時間 | 5,473 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
52,200 KB |
testcase_01 | AC | 47 ms
51,576 KB |
testcase_02 | AC | 51 ms
51,920 KB |
testcase_03 | AC | 52 ms
51,812 KB |
testcase_04 | AC | 48 ms
51,800 KB |
testcase_05 | AC | 50 ms
51,656 KB |
testcase_06 | AC | 48 ms
51,596 KB |
testcase_07 | AC | 54 ms
51,712 KB |
testcase_08 | AC | 78 ms
54,300 KB |
testcase_09 | AC | 139 ms
55,908 KB |
testcase_10 | AC | 102 ms
55,552 KB |
testcase_11 | AC | 111 ms
55,632 KB |
testcase_12 | AC | 117 ms
55,792 KB |
testcase_13 | AC | 109 ms
56,284 KB |
testcase_14 | AC | 95 ms
55,020 KB |
testcase_15 | AC | 56 ms
52,204 KB |
testcase_16 | AC | 86 ms
54,836 KB |
testcase_17 | AC | 53 ms
52,204 KB |
testcase_18 | AC | 51 ms
49,724 KB |
testcase_19 | AC | 49 ms
51,612 KB |
testcase_20 | AC | 49 ms
51,968 KB |
testcase_21 | AC | 52 ms
51,704 KB |
testcase_22 | AC | 154 ms
55,664 KB |
testcase_23 | AC | 107 ms
55,864 KB |
testcase_24 | AC | 64 ms
54,228 KB |
testcase_25 | AC | 51 ms
51,608 KB |
testcase_26 | AC | 48 ms
51,628 KB |
testcase_27 | AC | 155 ms
55,736 KB |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Iterator; public class Main { public static Scanner sc=new Scanner(System.in); public static Printer pr=new Printer(System.out); public static void main(String[] args) { int d = sc.nextInt(); for(;d>0;d--){ new Main().solver(); } pr.close(); } 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){ pr.println(i); return; } } pr.println(m); } void tr(Object...o){System.out.println(Arrays.deepToString(o));} private static class Scanner{ BufferedReader br; Iterator<String> it; Scanner(InputStream in){ br=new BufferedReader(new InputStreamReader(in)); } String next()throws RuntimeException{ try{ if(it==null||!it.hasNext()) it=Arrays.asList(br.readLine().split(" ")).iterator(); return it.next(); }catch(IOException e){ throw new IllegalStateException(); } } int nextInt() throws RuntimeException{ return Integer.parseInt(next()); } long nextLong() throws RuntimeException{ return Long.parseLong(next()); } double nextDouble() throws RuntimeException{ return Double.parseDouble(next()); } void close(){ try{ br.close(); }catch(IOException e){ throw new IllegalStateException(); } } } private static class Printer extends PrintWriter{ Printer(PrintStream out){ super(out); } } }