結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー ooooobaoooooba
提出日時 2021-03-03 21:16:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 846 ms
コンパイル使用メモリ 109,440 KB
最終ジャッジ日時 2025-01-19 09:47:37
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <optional>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int32_t n, k;
    cin >> n >> k;
    int32_t ans;
    if (k <= 0 || k > n)
        ans = 0;
    else if (n % 2 == 1 && k == n / 2 + 1)
        ans = n - 1;
    else
        ans = n - 2;
    cout << ans << endl;
    return 0;
}
0