結果
| 問題 | 
                            No.1052 電子機器X
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-05-15 22:25:34 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 1,000 ms | 
| コード長 | 646 bytes | 
| コンパイル時間 | 876 ms | 
| コンパイル使用メモリ | 83,344 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-19 11:14:04 | 
| 合計ジャッジ時間 | 1,664 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 16 | 
ソースコード
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  if(n % 2 == 0) {
    ans += (min(n, k) + 1) / 2;
    if(n % 2 != 0 || n > k * 2) {
      ans += min(n, k + 2) / 2;
    }
    if(n - k <= k) {
      ans = n / 2;
    }
  } else {
    ans += (min(n, k) + 1) / 2;
    if(n % 2 != 0 || n > k * 2) {
      ans = min(n, ans + (k + 2) / 2);
    }
  }
  cout << ans << endl;
  return 0;
}