結果

問題 No.1052 電子機器X
ユーザー mmn15277198
提出日時 2021-02-07 18:29:55
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 523 bytes
コンパイル時間 509 ms
コンパイル使用メモリ 68,596 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-04 11:33:29
合計ジャッジ時間 1,319 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n , k;
    cin >> n >> k;
    
    if(k >= n){
        cout << n << endl;
        exit(0);
    }
    
    ll ans;
    if(n % 2 == 0){
        if(k % 2 == 0)ans = min(k + 1 , n / 2);
        else ans = min(k , n / 2);
    }else{
        if(k % 2 == 0)ans = min((k + 1) / 2 + (k + 1) / 2 + 1 , n);
        else ans = min((k + 1) / 2 + (k + 1) / 2 , n);
    }
    cout << ans << endl;
    return 0;
}


0