結果

問題 No.115 遠足のおやつ
ユーザー tentententen
提出日時 2020-11-17 19:43:54
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,112 bytes
コンパイル時間 2,126 ms
コンパイル使用メモリ 74,640 KB
実行使用メモリ 57,888 KB
最終ジャッジ日時 2023-09-30 14:23:56
合計ジャッジ時間 9,891 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 124 ms
55,924 KB
testcase_02 AC 125 ms
56,340 KB
testcase_03 AC 123 ms
56,164 KB
testcase_04 AC 124 ms
56,104 KB
testcase_05 AC 125 ms
55,976 KB
testcase_06 AC 126 ms
55,812 KB
testcase_07 AC 126 ms
55,928 KB
testcase_08 AC 125 ms
55,976 KB
testcase_09 AC 124 ms
55,696 KB
testcase_10 AC 124 ms
55,860 KB
testcase_11 AC 126 ms
55,860 KB
testcase_12 AC 127 ms
55,552 KB
testcase_13 AC 124 ms
55,988 KB
testcase_14 AC 127 ms
55,528 KB
testcase_15 AC 126 ms
55,924 KB
testcase_16 AC 127 ms
55,700 KB
testcase_17 AC 125 ms
55,804 KB
testcase_18 AC 126 ms
55,668 KB
testcase_19 AC 125 ms
56,032 KB
testcase_20 AC 124 ms
56,068 KB
testcase_21 AC 124 ms
55,912 KB
testcase_22 AC 126 ms
55,788 KB
testcase_23 AC 126 ms
55,732 KB
testcase_24 AC 126 ms
56,040 KB
testcase_25 AC 126 ms
56,140 KB
testcase_26 AC 125 ms
56,016 KB
testcase_27 AC 125 ms
55,884 KB
testcase_28 AC 124 ms
55,924 KB
testcase_29 AC 125 ms
55,780 KB
testcase_30 AC 125 ms
55,884 KB
testcase_31 AC 125 ms
56,000 KB
testcase_32 AC 123 ms
55,996 KB
testcase_33 AC 124 ms
56,096 KB
testcase_34 AC 125 ms
56,060 KB
testcase_35 AC 125 ms
56,148 KB
testcase_36 AC 126 ms
55,752 KB
testcase_37 AC 124 ms
56,016 KB
testcase_38 AC 124 ms
55,780 KB
testcase_39 AC 123 ms
55,540 KB
testcase_40 AC 124 ms
55,976 KB
testcase_41 AC 124 ms
56,356 KB
testcase_42 AC 123 ms
55,724 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();
        int[] arr = new int[k];
        for (int i = 0; i < k; i++) {
            arr[i] = i + 1;
            d -= i + 1;
        }
        if (d < 0) {
            System.out.println(-1);
            return;
        }
        int max = n;
        for (int i = k - 1; i >= 0 && d > 0; i--) {
            if (d + arr[i] - max >= 0) {
                d += arr[i];
                arr[i] = max;
                d -= max;
                max--;
            } else {
                arr[i] += d;
                d = 0;
            }
        }
        if (d > 0) {
            System.out.println(-1);
        } else {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < k; i++) {
                if (i > 0) {
                    sb.append(" ");
                }
                sb.append(arr[i]);
            }
            System.out.println(sb);
        }
    }
}
0