結果

問題 No.257 N言っちゃダメゲーム (3)
ユーザー shimashimau67shimashimau67
提出日時 2015-08-01 16:12:32
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,777 bytes
コンパイル時間 2,300 ms
コンパイル使用メモリ 100,860 KB
実行使用メモリ 50,980 KB
平均クエリ数 0.73
最終ジャッジ日時 2023-09-23 21:14:15
合計ジャッジ時間 7,095 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
38,852 KB
testcase_01 AC 99 ms
36,868 KB
testcase_02 AC 97 ms
36,456 KB
testcase_03 AC 96 ms
36,868 KB
testcase_04 AC 93 ms
36,328 KB
testcase_05 AC 96 ms
36,516 KB
testcase_06 AC 95 ms
36,840 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
        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.Count <= 1)
        {
            Console.WriteLine(0);
        }
        else if (list[list.Count - 1] > K)
        {
            Console.WriteLine(0);
        }
        else
        {
            Console.WriteLine(list[list.Count - 1]);
        }
        
        while (true)
        {
            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