結果

問題 No.257 N言っちゃダメゲーム (3)
ユーザー shimashimau67shimashimau67
提出日時 2015-08-01 16:04:08
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,765 bytes
コンパイル時間 2,250 ms
コンパイル使用メモリ 100,984 KB
実行使用メモリ 38,864 KB
平均クエリ数 3.70
最終ジャッジ日時 2023-09-23 05:24:01
合計ジャッジ時間 7,090 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
36,968 KB
testcase_01 AC 99 ms
38,676 KB
testcase_02 AC 98 ms
36,724 KB
testcase_03 AC 99 ms
36,924 KB
testcase_04 AC 98 ms
38,404 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 99 ms
38,824 KB
testcase_08 AC 100 ms
36,508 KB
testcase_09 AC 98 ms
36,896 KB
testcase_10 AC 98 ms
36,716 KB
testcase_11 AC 107 ms
38,836 KB
testcase_12 AC 98 ms
34,604 KB
testcase_13 AC 99 ms
38,864 KB
testcase_14 AC 98 ms
36,616 KB
testcase_15 AC 97 ms
38,696 KB
testcase_16 AC 96 ms
37,032 KB
testcase_17 AC 98 ms
36,556 KB
testcase_18 AC 95 ms
36,876 KB
testcase_19 AC 99 ms
37,060 KB
testcase_20 AC 101 ms
36,452 KB
testcase_21 AC 100 ms
36,532 KB
testcase_22 AC 97 ms
38,396 KB
testcase_23 AC 96 ms
38,416 KB
testcase_24 AC 97 ms
36,972 KB
testcase_25 AC 99 ms
36,804 KB
testcase_26 AC 100 ms
38,648 KB
testcase_27 AC 98 ms
36,344 KB
testcase_28 AC 101 ms
38,348 KB
testcase_29 AC 100 ms
36,776 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.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        /*N - 1取れば勝ち
         *N - 2 ~ N - K - 1取ったら負ける
         *N - K - 2取れば勝ち
         *N - K - 2 ~ N - K * 2 - 2取ったら負ける
         *N - K * 2 - 3取れば勝ち
         */
        String[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);//言っちゃダメなやつ
        int K = int.Parse(input[1]);//言える上限数
        int num = 0;
        int count = 0;
        List<int> list = new List<int>();
        for (int i = 0; N - (K * i) - (1 + i) > 0; i++)
        {
            list.Add(N - (K * i) - (1 + i));//大きい順に並べられます 
        }
        if (list[list.Count - 1] > K)
        {
            Console.WriteLine(0);
        }
        else
        {
            Console.WriteLine(list[list.Count - 1]);
        }
        
        while (true)
        {
            count++;
            num = int.Parse(Console.ReadLine());
            if (num >= N) break;
            else
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[list.Count - 1 - i] > num)
                    {
                        Console.WriteLine(list[list.Count - 1 - i]);
                        break;
                    }
                }
            }
        }
    }
    /*
     二部探索のテクニック
     * 最大値を+1した数からスタートした方がやりやすい
     * 考えうる最大値と最小値を足した値/2から求める
     * てんてんててんててんてんててん
     * http://yukicoder.me/submissions/36416 ←参考にすべき(1問目)
     * 
     */
}
0