結果
問題 |
No.1052 電子機器X
|
ユーザー |
![]() |
提出日時 | 2020-05-15 23:50:12 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 21 ms / 1,000 ms |
コード長 | 1,951 bytes |
コンパイル時間 | 4,025 ms |
コンパイル使用メモリ | 106,240 KB |
実行使用メモリ | 17,920 KB |
最終ジャッジ日時 | 2024-09-19 14:27:45 |
合計ジャッジ時間 | 3,337 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; using CompLib.Util; public class Program { public void Solve() { var sc = new Scanner(); int n = sc.NextInt(); int k = sc.NextInt(); // +側 min,max // k回押す 1 + k 以下 偶奇一致 // n-k+1以上 偶奇一致 if (n % 2 == 1) { Console.WriteLine(Math.Min(k + 1, n)); } else { Console.WriteLine(Math.Min(k + 1, n / 2)); } } public static void Main(string[] args) => new Program().Solve(); } namespace CompLib.Util { using System; using System.Linq; class Scanner { private string[] _line; private int _index; private const char Separator = ' '; public Scanner() { _line = new string[0]; _index = 0; } public string Next() { while (_index >= _line.Length) { _line = Console.ReadLine().Split(Separator); _index = 0; } return _line[_index++]; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); public decimal NextDecimal() => decimal.Parse(Next()); public char NextChar() => Next()[0]; public char[] NextCharArray() => Next().ToCharArray(); public string[] Array() { _line = Console.ReadLine().Split(Separator); _index = _line.Length; return _line; } public int[] IntArray() => Array().Select(int.Parse).ToArray(); public long[] LongArray() => Array().Select(long.Parse).ToArray(); public double[] DoubleArray() => Array().Select(double.Parse).ToArray(); public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray(); } }