結果

問題 No.115 遠足のおやつ
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-06-07 15:56:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 356 ms / 5,000 ms
コード長 1,623 bytes
コンパイル時間 4,011 ms
コンパイル使用メモリ 80,704 KB
実行使用メモリ 88,744 KB
最終ジャッジ日時 2023-08-31 00:34:42
合計ジャッジ時間 15,868 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
56,752 KB
testcase_01 AC 168 ms
59,156 KB
testcase_02 AC 189 ms
61,224 KB
testcase_03 AC 160 ms
57,080 KB
testcase_04 AC 301 ms
81,556 KB
testcase_05 AC 176 ms
58,916 KB
testcase_06 AC 166 ms
58,772 KB
testcase_07 AC 193 ms
61,352 KB
testcase_08 AC 172 ms
58,876 KB
testcase_09 AC 193 ms
61,876 KB
testcase_10 AC 219 ms
61,728 KB
testcase_11 AC 163 ms
59,256 KB
testcase_12 AC 188 ms
61,236 KB
testcase_13 AC 167 ms
58,792 KB
testcase_14 AC 220 ms
61,776 KB
testcase_15 AC 285 ms
69,852 KB
testcase_16 AC 329 ms
82,032 KB
testcase_17 AC 322 ms
70,804 KB
testcase_18 AC 181 ms
65,848 KB
testcase_19 AC 253 ms
68,684 KB
testcase_20 AC 197 ms
61,272 KB
testcase_21 AC 199 ms
64,040 KB
testcase_22 AC 266 ms
66,804 KB
testcase_23 AC 178 ms
59,368 KB
testcase_24 AC 253 ms
66,520 KB
testcase_25 AC 307 ms
73,296 KB
testcase_26 AC 246 ms
65,952 KB
testcase_27 AC 251 ms
65,984 KB
testcase_28 AC 228 ms
61,556 KB
testcase_29 AC 281 ms
68,864 KB
testcase_30 AC 256 ms
66,704 KB
testcase_31 AC 255 ms
66,020 KB
testcase_32 AC 288 ms
73,396 KB
testcase_33 AC 241 ms
66,096 KB
testcase_34 AC 310 ms
81,760 KB
testcase_35 AC 290 ms
69,144 KB
testcase_36 AC 249 ms
66,808 KB
testcase_37 AC 302 ms
81,816 KB
testcase_38 AC 356 ms
88,484 KB
testcase_39 AC 345 ms
88,744 KB
testcase_40 AC 164 ms
56,708 KB
testcase_41 AC 165 ms
56,880 KB
testcase_42 AC 180 ms
57,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class No0115 {
    
    static final Scanner in = new Scanner(System.in);
    static final PrintWriter out = new PrintWriter(System.out,false);

    static void solve() {
        int n = in.nextInt();
        int d = in.nextInt();
        int K = in.nextInt();

        String[][][] dp = new String[n+1][2000][K+2];
        dp[0][0][0] = "";

        for (int i=0; i<n; i++) {
        	for (int j=0; j<=d; j++) {
        		for (int k=0; k<=K; k++) {
        			if (dp[i][j][k] == null) continue;
        			dp[i+1][i+j+1][k+1] = 
        				(dp[i+1][i+j+1][k+1] == null || dp[i+1][i+j+1][k+1].compareTo(dp[i][j][k]+(char)(i+1)) > 0)
        				? (dp[i][j][k]+(char)(i+1)) : dp[i+1][i+j+1][k+1];
        			dp[i+1][j][k] = (dp[i+1][j][k] == null || dp[i+1][j][k].compareTo(dp[i][j][k]) > 0)
        				? dp[i][j][k] : dp[i+1][j][k];
        		}
        	}
        }
        
        if (dp[n][d][K] == null) {
        	out.println("-1");
        } else {
        	for(int i=0; i<dp[n][d][K].length()-1; i++) {
        		out.print((int)dp[n][d][K].charAt(i)+" ");
        	}
        	out.println((int)dp[n][d][K].charAt(dp[n][d][K].length()-1));
        }
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();

        solve();
        out.flush();

        long end = System.currentTimeMillis();
        //trace(end-start + "ms");
        in.close();
        out.close();
    }

    static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}
0