結果

問題 No.115 遠足のおやつ
ユーザー しらゆきしらゆき
提出日時 2015-12-27 13:38:24
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 870 bytes
コンパイル時間 830 ms
コンパイル使用メモリ 106,140 KB
実行使用メモリ 24,120 KB
最終ジャッジ日時 2023-10-19 11:14:04
合計ジャッジ時間 3,738 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
24,100 KB
testcase_01 AC 26 ms
24,100 KB
testcase_02 WA -
testcase_03 AC 26 ms
24,100 KB
testcase_04 WA -
testcase_05 AC 26 ms
24,116 KB
testcase_06 AC 25 ms
24,100 KB
testcase_07 AC 26 ms
24,116 KB
testcase_08 AC 27 ms
24,100 KB
testcase_09 AC 26 ms
24,100 KB
testcase_10 AC 27 ms
24,100 KB
testcase_11 AC 27 ms
24,100 KB
testcase_12 AC 26 ms
24,100 KB
testcase_13 AC 25 ms
24,100 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 26 ms
24,116 KB
testcase_18 AC 26 ms
24,100 KB
testcase_19 AC 26 ms
24,116 KB
testcase_20 AC 25 ms
24,120 KB
testcase_21 AC 25 ms
24,096 KB
testcase_22 WA -
testcase_23 AC 25 ms
24,100 KB
testcase_24 WA -
testcase_25 AC 26 ms
24,120 KB
testcase_26 AC 26 ms
24,116 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 26 ms
24,116 KB
testcase_30 WA -
testcase_31 AC 25 ms
24,116 KB
testcase_32 WA -
testcase_33 AC 26 ms
24,116 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 25 ms
24,100 KB
testcase_41 AC 25 ms
24,100 KB
testcase_42 AC 26 ms
24,116 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