結果

問題 No.1052 電子機器X
ユーザー horoyoisawahoroyoisawa
提出日時 2022-02-01 09:55:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 459 bytes
コンパイル時間 1,374 ms
コンパイル使用メモリ 165,060 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 02:28:38
合計ジャッジ時間 2,527 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    if(2 * k + 1 <= n) ans = (2 * k + 1) / 2 + 1;
    else {
        int low = (-k) % n;
        int high = k % n;
        if(low < 0) low += n;
        if(abs(low - high) % 2 == 0) {
            ans = n / 2;
            if(k % 2 == 0 && n % 2 == 1) ans++;
        }
        else ans = min(n, (2 * k + 1) / 2 + 1);
    }

    cout << ans << endl;;
}
0