結果

問題 No.1860 Magnets
ユーザー ayataka5
提出日時 2022-03-04 21:35:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 338 bytes
コンパイル時間 2,039 ms
コンパイル使用メモリ 193,220 KB
最終ジャッジ日時 2025-01-28 04:55:21
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll = long long;

int main() {
    int A, B;
    cin >> A >> B;
    ll ans;
    if(A < B-1) {
        ans = (A*2+1) + 2*((B-1)-A);
    }else if(A > B+1){
        ans = (B*2+1) + 2*(A-(B+1));
    }else {
        ans = min((A*2)+1, (B*2)+1);
    }
    cout << ans << endl;
    return 0;
}
0