結果

問題 No.115 遠足のおやつ
ユーザー しらゆきしらゆき
提出日時 2015-12-27 13:43:52
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 56 ms / 5,000 ms
コード長 870 bytes
コンパイル時間 1,694 ms
コンパイル使用メモリ 101,912 KB
実行使用メモリ 24,932 KB
最終ジャッジ日時 2023-08-31 00:36:32
合計ジャッジ時間 5,387 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
20,812 KB
testcase_01 AC 52 ms
22,752 KB
testcase_02 AC 52 ms
20,684 KB
testcase_03 AC 55 ms
18,672 KB
testcase_04 AC 52 ms
22,804 KB
testcase_05 AC 54 ms
20,720 KB
testcase_06 AC 52 ms
20,736 KB
testcase_07 AC 53 ms
20,688 KB
testcase_08 AC 51 ms
22,908 KB
testcase_09 AC 49 ms
20,704 KB
testcase_10 AC 52 ms
20,780 KB
testcase_11 AC 50 ms
20,844 KB
testcase_12 AC 53 ms
20,812 KB
testcase_13 AC 51 ms
20,788 KB
testcase_14 AC 53 ms
22,780 KB
testcase_15 AC 53 ms
20,740 KB
testcase_16 AC 52 ms
20,888 KB
testcase_17 AC 52 ms
20,840 KB
testcase_18 AC 49 ms
18,784 KB
testcase_19 AC 53 ms
20,848 KB
testcase_20 AC 54 ms
20,800 KB
testcase_21 AC 52 ms
22,832 KB
testcase_22 AC 54 ms
20,856 KB
testcase_23 AC 49 ms
20,828 KB
testcase_24 AC 53 ms
22,852 KB
testcase_25 AC 55 ms
22,908 KB
testcase_26 AC 53 ms
20,820 KB
testcase_27 AC 52 ms
20,872 KB
testcase_28 AC 55 ms
20,864 KB
testcase_29 AC 52 ms
22,736 KB
testcase_30 AC 53 ms
20,884 KB
testcase_31 AC 52 ms
20,744 KB
testcase_32 AC 56 ms
22,792 KB
testcase_33 AC 52 ms
24,932 KB
testcase_34 AC 53 ms
20,840 KB
testcase_35 AC 52 ms
22,728 KB
testcase_36 AC 51 ms
20,792 KB
testcase_37 AC 56 ms
20,756 KB
testcase_38 AC 54 ms
22,788 KB
testcase_39 AC 52 ms
20,660 KB
testcase_40 AC 51 ms
20,908 KB
testcase_41 AC 51 ms
20,840 KB
testcase_42 AC 55 ms
20,756 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class Program
{
    static void Main()
    {
        var s = Console.ReadLine().Split();
        int n = int.Parse(s[0]);
        int d = int.Parse(s[1]);
        int k = int.Parse(s[2]);

        if (k > n)
        {
            Console.WriteLine(-1);
            return;
        }

        int min = k * (1 + k) / 2;
        int max = k * (2 * n - k + 1) / 2;
        if (d > max || d < min)
        {
            Console.WriteLine(-1);
            return;
        }

        for (int i = 1; i <= n; i++)
        {
            if (k == 1 && i == d)
            {
                Console.Write(i);
                break;
            }
            if (d - i <= (k - 1) * (2 * n - k + 2) / 2)
            {
                Console.Write("{0} ", i);
                k--;
                d -= i;
            }

        }
        Console.WriteLine();
    }
}
0