結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-21 08:48:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 357 bytes
コンパイル時間 1,855 ms
コンパイル使用メモリ 74,284 KB
実行使用メモリ 54,340 KB
最終ジャッジ日時 2024-04-10 07:05:38
合計ジャッジ時間 6,140 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
54,028 KB
testcase_01 AC 108 ms
53,136 KB
testcase_02 AC 103 ms
53,020 KB
testcase_03 AC 110 ms
53,092 KB
testcase_04 AC 110 ms
53,340 KB
testcase_05 AC 124 ms
54,260 KB
testcase_06 AC 124 ms
53,876 KB
testcase_07 AC 122 ms
54,008 KB
testcase_08 AC 125 ms
54,256 KB
testcase_09 AC 109 ms
52,960 KB
testcase_10 AC 104 ms
52,692 KB
testcase_11 AC 124 ms
53,900 KB
testcase_12 AC 102 ms
52,344 KB
testcase_13 AC 126 ms
53,812 KB
testcase_14 AC 112 ms
53,392 KB
testcase_15 AC 106 ms
52,712 KB
testcase_16 AC 119 ms
54,196 KB
testcase_17 AC 122 ms
54,024 KB
testcase_18 AC 114 ms
54,136 KB
testcase_19 AC 105 ms
52,720 KB
testcase_20 AC 105 ms
52,764 KB
testcase_21 AC 114 ms
54,144 KB
testcase_22 AC 114 ms
53,792 KB
testcase_23 AC 114 ms
54,120 KB
testcase_24 AC 113 ms
53,864 KB
testcase_25 AC 121 ms
54,008 KB
testcase_26 AC 119 ms
53,996 KB
testcase_27 AC 117 ms
54,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int ans = 0;
    if((K > 0) && (K <= N)) {
      if(K - 1 == N - K) {
        ans = N - 1;
      } else {
        ans = N - 2;
      }
    }
    System.out.println(ans);
  }
}
0