結果

問題 No.1860 Magnets
ユーザー OmameBeans
提出日時 2022-03-17 23:10:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 375 bytes
コンパイル時間 1,530 ms
コンパイル使用メモリ 166,696 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-01 22:16:42
合計ジャッジ時間 2,668 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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