結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー sekiya9311sekiya9311
提出日時 2017-06-03 11:37:00
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 1,820 bytes
コンパイル時間 3,922 ms
コンパイル使用メモリ 110,316 KB
実行使用メモリ 24,160 KB
最終ジャッジ日時 2023-10-22 02:51:54
合計ジャッジ時間 3,716 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
24,156 KB
testcase_01 AC 21 ms
24,156 KB
testcase_02 AC 21 ms
24,156 KB
testcase_03 AC 22 ms
24,156 KB
testcase_04 AC 23 ms
24,156 KB
testcase_05 AC 23 ms
24,160 KB
testcase_06 AC 21 ms
24,160 KB
testcase_07 AC 21 ms
24,160 KB
testcase_08 AC 24 ms
24,160 KB
testcase_09 AC 23 ms
24,156 KB
testcase_10 AC 24 ms
24,156 KB
testcase_11 AC 23 ms
24,160 KB
testcase_12 AC 21 ms
24,160 KB
testcase_13 AC 20 ms
24,156 KB
testcase_14 AC 22 ms
24,156 KB
testcase_15 AC 21 ms
24,156 KB
testcase_16 AC 22 ms
24,156 KB
testcase_17 AC 22 ms
24,156 KB
testcase_18 AC 23 ms
24,156 KB
testcase_19 AC 23 ms
24,156 KB
testcase_20 AC 21 ms
24,156 KB
testcase_21 AC 22 ms
24,156 KB
testcase_22 AC 21 ms
24,160 KB
testcase_23 AC 22 ms
24,160 KB
testcase_24 AC 22 ms
24,160 KB
testcase_25 AC 21 ms
24,160 KB
testcase_26 AC 21 ms
24,156 KB
testcase_27 AC 22 ms
24,156 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;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Competitive_Programming
{
    class MainClass
    {
        Scanner sc;
        static void Main(string[] args)
        {
            new MainClass().solve();
        }

        void solve()
        {
            sc = new Scanner();
            int N = sc.NextInt();
            int K = sc.NextInt();
            int ans;
            if (K == 0 || K > N)
            {
                ans = 0;
            }
            else
            {
                if (N % 2 == 1 && (N + 1) / 2 == K)
                {
                    ans = N - 1;
                }
                else
                {
                    ans = N - 2;
                }
            }
            Console.WriteLine(ans);
        }
    }
    
    class Scanner
    {
        Queue<string> buf;
        public Scanner()
        {
            buf = new Queue<string>();
            this.GetBuf();
        }
        private void GetBuf()
        {
            if (buf.Count == 0)
            {
                string[] stringArray = Console.ReadLine().Split(new char[] { ' ' });
                foreach (string e in stringArray)
                {
                    buf.Enqueue(e);
                }
            }
        }
        public int NextInt()
        {
            this.GetBuf();
            return int.Parse(buf.Dequeue());
        }
        public long NextLong()
        {
            this.GetBuf();
            return long.Parse(buf.Dequeue());
        }
        public double NextDouble()
        {
            this.GetBuf();
            return double.Parse(buf.Dequeue());
        }
        public string Next()
        {
            this.GetBuf();
            return buf.Dequeue();
        }
    }
}
0