結果

問題 No.1057 素敵な日
ユーザー KKT89KKT89
提出日時 2020-05-22 21:29:46
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,593 bytes
コンパイル時間 1,024 ms
コンパイル使用メモリ 99,912 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 15:54:40
合計ジャッジ時間 1,513 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <map>
#include <math.h>
#include <stack>
#include <math.h>
using namespace std;
typedef long long int ll;


using ull = unsigned long long;
int bsf(ull x) { return __builtin_ctzll(x); }
struct fastset{
    int N,lg;
    vector<vector<ull>> seg;
    fastset(int N):N(N){
        while(N>1){
            seg.push_back(vector<ull>((N+63)/64));
            N=(N+63)/64;
        }
        lg=seg.size();
    }
    void ins(int x){
        for(int i=0;i<lg;i++){
            int D=x/64,R=x%64;
            seg[i][D]|=(1ULL<<R);
            x/=64;
        }
    }
    void cle(int x){
        for(int i=0;i<lg;i++){
            int D=x/64,R=x%64;
            seg[i][D] &= ~(!1ULL<<R);
            if(i&&seg[i-1][x]!=0){
                seg[i][D]|=(1ULL<<R);
            }
            x/=64;
        }
    }
    // x以上の最小の要素
    int upp(int x){
        for(int i=0;i<lg;i++){
            int D=x/64,R=x%64;
            if(D==seg[i].size())break;
            ull B=seg[i][D]>>R;
            if(!B){
                x=x/64+1;
                continue;
            }
            // find
            x+=bsf(B);
            for(int j=i-1;j>=0;j--){
                x*=64;
                int D=x/64;
                x+=bsf(seg[j][D]);
            }
            return x;
        }
        return N;
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b; cin >> a >> b;
    int dif=abs(a-b);
    cout << a+b-max(dif-1,0)-1 << endl;
}
0