結果

問題 No.115 遠足のおやつ
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2017-01-12 03:03:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 283 ms / 5,000 ms
コード長 913 bytes
コンパイル時間 2,342 ms
コンパイル使用メモリ 76,700 KB
実行使用メモリ 60,364 KB
最終ジャッジ日時 2023-08-31 00:42:27
合計ジャッジ時間 12,490 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
56,900 KB
testcase_01 AC 165 ms
56,532 KB
testcase_02 AC 173 ms
56,828 KB
testcase_03 AC 166 ms
57,072 KB
testcase_04 AC 283 ms
60,172 KB
testcase_05 AC 162 ms
57,252 KB
testcase_06 AC 161 ms
57,024 KB
testcase_07 AC 168 ms
57,200 KB
testcase_08 AC 164 ms
54,856 KB
testcase_09 AC 167 ms
57,332 KB
testcase_10 AC 166 ms
57,080 KB
testcase_11 AC 161 ms
56,832 KB
testcase_12 AC 161 ms
57,236 KB
testcase_13 AC 161 ms
56,948 KB
testcase_14 AC 179 ms
57,112 KB
testcase_15 AC 230 ms
60,124 KB
testcase_16 AC 271 ms
60,216 KB
testcase_17 AC 226 ms
59,296 KB
testcase_18 AC 164 ms
57,132 KB
testcase_19 AC 170 ms
58,628 KB
testcase_20 AC 173 ms
56,756 KB
testcase_21 AC 160 ms
56,828 KB
testcase_22 AC 221 ms
60,364 KB
testcase_23 AC 170 ms
57,152 KB
testcase_24 AC 226 ms
59,804 KB
testcase_25 AC 224 ms
59,496 KB
testcase_26 AC 205 ms
57,032 KB
testcase_27 AC 202 ms
58,864 KB
testcase_28 AC 196 ms
56,856 KB
testcase_29 AC 206 ms
59,084 KB
testcase_30 AC 228 ms
59,332 KB
testcase_31 AC 208 ms
57,244 KB
testcase_32 AC 257 ms
59,892 KB
testcase_33 AC 173 ms
57,092 KB
testcase_34 AC 259 ms
60,200 KB
testcase_35 AC 230 ms
59,456 KB
testcase_36 AC 213 ms
59,576 KB
testcase_37 AC 252 ms
59,860 KB
testcase_38 AC 213 ms
59,820 KB
testcase_39 AC 216 ms
59,168 KB
testcase_40 AC 161 ms
56,724 KB
testcase_41 AC 158 ms
57,056 KB
testcase_42 AC 160 ms
56,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();
        int K = sc.nextInt();
        boolean [][] b = new boolean [K+1][D+1];
        String [][] s = new String [K+1][D+1];
        for(int i=0; i<=K; i++){
            for(int j=0; j<=D; j++){
                s[i][j]="";
            }
        }
        b[0][0]=true;
        for(int i=1; i<=N; i++){
            for(int j=D; j>=0; j--){
                for(int k=0; k<K; k++){
                    if(b[k][j]&&i+j<=D){
                        b[k+1][i+j]=true;
                        s[k+1][i+j]=s[k][j]+" "+i;
                    }
                }
            }
        }
        if(b[K][D]){
            System.out.println(s[K][D].substring(1));
        }else{
            System.out.println(-1);
        }
    }
}
0