結果
| 問題 |
No.257 N言っちゃダメゲーム (3)
|
| コンテスト | |
| ユーザー |
shimashimau67
|
| 提出日時 | 2015-08-01 16:12:32 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,777 bytes |
| コンパイル時間 | 955 ms |
| コンパイル使用メモリ | 110,024 KB |
| 実行使用メモリ | 57,724 KB |
| 平均クエリ数 | 0.73 |
| 最終ジャッジ日時 | 2024-07-16 21:04:02 |
| 合計ジャッジ時間 | 5,338 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 TLE * 1 -- * 22 |
コンパイルメッセージ
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;
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問目)
*
*/
}
shimashimau67