結果
| 問題 | 
                            No.257 N言っちゃダメゲーム (3)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             shimashimau67
                         | 
                    
| 提出日時 | 2015-08-01 16:04:08 | 
| 言語 | C#(csc)  (csc 3.9.0)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,765 bytes | 
| コンパイル時間 | 872 ms | 
| コンパイル使用メモリ | 109,232 KB | 
| 実行使用メモリ | 42,848 KB | 
| 平均クエリ数 | 3.70 | 
| 最終ジャッジ日時 | 2024-07-16 05:24:07 | 
| 合計ジャッジ時間 | 5,402 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 28 RE * 2 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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問目)
     * 
     */
}
            
            
            
        
            
shimashimau67