結果
問題 | No.115 遠足のおやつ |
ユーザー | chiho_miyako |
提出日時 | 2015-04-16 19:10:54 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 276 ms / 5,000 ms |
コード長 | 1,404 bytes |
コンパイル時間 | 6,191 ms |
コンパイル使用メモリ | 76,440 KB |
実行使用メモリ | 116,012 KB |
最終ジャッジ日時 | 2023-08-31 00:33:39 |
合計ジャッジ時間 | 16,076 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 124 ms
55,760 KB |
testcase_01 | AC | 126 ms
55,852 KB |
testcase_02 | AC | 148 ms
56,088 KB |
testcase_03 | AC | 124 ms
55,988 KB |
testcase_04 | AC | 247 ms
92,872 KB |
testcase_05 | AC | 143 ms
56,164 KB |
testcase_06 | AC | 126 ms
56,180 KB |
testcase_07 | AC | 164 ms
56,968 KB |
testcase_08 | AC | 126 ms
55,964 KB |
testcase_09 | AC | 149 ms
59,076 KB |
testcase_10 | AC | 150 ms
58,656 KB |
testcase_11 | AC | 123 ms
56,436 KB |
testcase_12 | AC | 163 ms
65,400 KB |
testcase_13 | AC | 126 ms
55,776 KB |
testcase_14 | AC | 164 ms
56,952 KB |
testcase_15 | AC | 204 ms
72,192 KB |
testcase_16 | AC | 265 ms
115,688 KB |
testcase_17 | AC | 244 ms
88,132 KB |
testcase_18 | AC | 190 ms
79,364 KB |
testcase_19 | AC | 212 ms
79,172 KB |
testcase_20 | AC | 162 ms
56,904 KB |
testcase_21 | AC | 267 ms
115,832 KB |
testcase_22 | AC | 183 ms
65,760 KB |
testcase_23 | AC | 129 ms
55,772 KB |
testcase_24 | AC | 171 ms
59,028 KB |
testcase_25 | AC | 266 ms
116,012 KB |
testcase_26 | AC | 168 ms
59,236 KB |
testcase_27 | AC | 170 ms
61,340 KB |
testcase_28 | AC | 163 ms
58,580 KB |
testcase_29 | AC | 241 ms
88,240 KB |
testcase_30 | AC | 173 ms
61,604 KB |
testcase_31 | AC | 242 ms
87,812 KB |
testcase_32 | AC | 231 ms
88,456 KB |
testcase_33 | AC | 267 ms
115,852 KB |
testcase_34 | AC | 243 ms
87,688 KB |
testcase_35 | AC | 214 ms
79,128 KB |
testcase_36 | AC | 165 ms
58,852 KB |
testcase_37 | AC | 276 ms
115,604 KB |
testcase_38 | AC | 273 ms
115,896 KB |
testcase_39 | AC | 255 ms
113,804 KB |
testcase_40 | AC | 125 ms
55,756 KB |
testcase_41 | AC | 125 ms
55,800 KB |
testcase_42 | AC | 143 ms
56,680 KB |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner koko = new Scanner(System.in); int n = koko.nextInt(); int d = koko.nextInt(); int k = koko.nextInt(); int mx = n*(n+1)/2; boolean[][][] price = new boolean[n+1][Math.max((n+1),k)+1][Math.max(mx,d)+1]; price[0][0][0]=true; for(int x=0; x<n; x++){ for(int y=0; y<=x; y++){ for(int z=0; z<mx; z++){ if(price[x][y][z]){ price[x+1][y][z]=true; price[x+1][y+1][z+x+1]=true; } } } } boolean judge = false; for(int x=n; x>0; x--){ if(price[x][k][d]){ judge=true; int[] a = new int[k]; int b =0; while(x>0){ if(x<=d&&price[x-1][k-1][d-x]){ a[b++]=x; k--; d=d-x; x--; }else{ x--; } } Arrays.sort(a); for(int i=0; i<b; i++){ System.out.print(a[i]+" "); } break; } } if(!judge){ System.out.println(-1); } } }