結果

問題 No.115 遠足のおやつ
ユーザー AreTrashAreTrash
提出日時 2016-06-01 02:57:23
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 1,836 bytes
コンパイル時間 2,040 ms
コンパイル使用メモリ 107,228 KB
実行使用メモリ 23,772 KB
最終ジャッジ日時 2023-08-31 00:38:45
合計ジャッジ時間 5,646 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
21,636 KB
testcase_01 AC 53 ms
23,576 KB
testcase_02 AC 54 ms
21,544 KB
testcase_03 AC 54 ms
23,772 KB
testcase_04 AC 54 ms
23,632 KB
testcase_05 AC 52 ms
23,580 KB
testcase_06 AC 53 ms
21,612 KB
testcase_07 AC 52 ms
23,712 KB
testcase_08 AC 54 ms
21,636 KB
testcase_09 AC 52 ms
21,456 KB
testcase_10 AC 54 ms
21,672 KB
testcase_11 AC 52 ms
21,644 KB
testcase_12 AC 52 ms
21,528 KB
testcase_13 AC 54 ms
21,716 KB
testcase_14 AC 51 ms
21,652 KB
testcase_15 AC 53 ms
21,636 KB
testcase_16 AC 52 ms
21,616 KB
testcase_17 AC 52 ms
23,660 KB
testcase_18 AC 53 ms
21,636 KB
testcase_19 AC 51 ms
21,556 KB
testcase_20 AC 51 ms
21,476 KB
testcase_21 AC 50 ms
23,672 KB
testcase_22 AC 53 ms
23,568 KB
testcase_23 AC 52 ms
19,628 KB
testcase_24 AC 52 ms
21,656 KB
testcase_25 AC 53 ms
21,524 KB
testcase_26 AC 52 ms
21,760 KB
testcase_27 AC 53 ms
21,552 KB
testcase_28 AC 52 ms
21,676 KB
testcase_29 AC 53 ms
21,544 KB
testcase_30 AC 54 ms
23,584 KB
testcase_31 AC 53 ms
19,468 KB
testcase_32 AC 52 ms
23,668 KB
testcase_33 AC 52 ms
21,620 KB
testcase_34 AC 53 ms
21,592 KB
testcase_35 AC 51 ms
21,568 KB
testcase_36 AC 52 ms
21,676 KB
testcase_37 AC 53 ms
21,548 KB
testcase_38 AC 53 ms
21,776 KB
testcase_39 AC 54 ms
21,648 KB
testcase_40 AC 53 ms
21,616 KB
testcase_41 AC 54 ms
21,536 KB
testcase_42 AC 54 ms
21,728 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;

namespace No115{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();
            var D = sr.Next<int>();
            var K = sr.Next<int>();

            var an = new int[K];
            for(var i = 0; i < K; i++){
                an[i] = N - K + 1 + i;
            }

            if(an.Sum() < D || K * K + K > D * 2) {
                Console.WriteLine(-1);
                return;
            }

            for(var i = 0; i < K; i++){
                if(an.Sum() - D + i >= an[i]){
                    an[i] = i + 1;
                } else{
                    an[i] -= an.Sum() - D;
                    break;
                }
            }

            Console.WriteLine(string.Join(" ", an));
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }
    }
}
0