結果

問題 No.257 N言っちゃダメゲーム (3)
ユーザー shimashimau67shimashimau67
提出日時 2015-08-01 16:15:26
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 1,776 bytes
コンパイル時間 3,152 ms
コンパイル使用メモリ 100,164 KB
実行使用メモリ 38,948 KB
平均クエリ数 3.70
最終ジャッジ日時 2023-09-23 21:14:47
合計ジャッジ時間 7,365 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
36,588 KB
testcase_01 AC 105 ms
36,864 KB
testcase_02 AC 104 ms
36,364 KB
testcase_03 AC 106 ms
38,704 KB
testcase_04 AC 105 ms
35,048 KB
testcase_05 AC 106 ms
36,840 KB
testcase_06 AC 105 ms
36,492 KB
testcase_07 AC 105 ms
37,080 KB
testcase_08 AC 106 ms
37,020 KB
testcase_09 AC 107 ms
36,968 KB
testcase_10 AC 106 ms
34,588 KB
testcase_11 AC 105 ms
36,948 KB
testcase_12 AC 104 ms
36,464 KB
testcase_13 AC 104 ms
36,712 KB
testcase_14 AC 106 ms
36,716 KB
testcase_15 AC 105 ms
36,660 KB
testcase_16 AC 105 ms
36,804 KB
testcase_17 AC 106 ms
36,604 KB
testcase_18 AC 105 ms
36,980 KB
testcase_19 AC 106 ms
36,352 KB
testcase_20 AC 108 ms
38,948 KB
testcase_21 AC 107 ms
36,396 KB
testcase_22 AC 105 ms
38,428 KB
testcase_23 AC 105 ms
36,376 KB
testcase_24 AC 106 ms
36,484 KB
testcase_25 AC 108 ms
36,396 KB
testcase_26 AC 105 ms
36,660 KB
testcase_27 AC 104 ms
36,516 KB
testcase_28 AC 106 ms
38,312 KB
testcase_29 AC 106 ms
38,612 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;
        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