結果

問題 No.115 遠足のおやつ
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-16 19:02:40
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,355 bytes
コンパイル時間 2,481 ms
コンパイル使用メモリ 76,668 KB
実行使用メモリ 116,076 KB
最終ジャッジ日時 2023-09-17 20:56:17
合計ジャッジ時間 12,574 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 150 ms
55,892 KB
testcase_03 RE -
testcase_04 AC 207 ms
92,752 KB
testcase_05 AC 140 ms
55,892 KB
testcase_06 AC 122 ms
55,616 KB
testcase_07 AC 139 ms
55,892 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 149 ms
58,380 KB
testcase_11 RE -
testcase_12 AC 148 ms
65,268 KB
testcase_13 AC 120 ms
56,488 KB
testcase_14 AC 137 ms
55,864 KB
testcase_15 AC 176 ms
72,064 KB
testcase_16 AC 198 ms
96,596 KB
testcase_17 AC 194 ms
88,024 KB
testcase_18 AC 139 ms
71,120 KB
testcase_19 AC 182 ms
79,096 KB
testcase_20 AC 138 ms
56,132 KB
testcase_21 AC 206 ms
115,900 KB
testcase_22 AC 166 ms
65,256 KB
testcase_23 RE -
testcase_24 AC 163 ms
58,728 KB
testcase_25 AC 213 ms
115,740 KB
testcase_26 AC 147 ms
57,904 KB
testcase_27 AC 165 ms
59,156 KB
testcase_28 AC 142 ms
57,952 KB
testcase_29 AC 197 ms
88,056 KB
testcase_30 AC 163 ms
61,128 KB
testcase_31 AC 197 ms
88,000 KB
testcase_32 AC 196 ms
88,032 KB
testcase_33 AC 211 ms
115,808 KB
testcase_34 AC 198 ms
88,004 KB
testcase_35 AC 178 ms
80,468 KB
testcase_36 AC 158 ms
58,848 KB
testcase_37 AC 210 ms
115,844 KB
testcase_38 AC 219 ms
116,076 KB
testcase_39 AC 202 ms
115,624 KB
testcase_40 RE -
testcase_41 AC 123 ms
55,816 KB
testcase_42 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
       boolean[][][] price = new boolean[n+1][n+1][n*(n+1)/2];
       price[0][0][0]=true;
       for(int x=0; x<n; x++){
           for(int y=0; y<=x; y++){
               for(int z=0; z<d+1; 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);
       }
    }
}
0