結果

問題 No.808 Kaiten Sushi?
ユーザー chocoruskchocorusk
提出日時 2019-03-31 07:04:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 221 ms / 2,000 ms
コード長 1,596 bytes
コンパイル時間 923 ms
コンパイル使用メモリ 102,220 KB
実行使用メモリ 14,428 KB
最終ジャッジ日時 2023-08-12 08:01:34
合計ジャッジ時間 10,133 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 3 ms
4,384 KB
testcase_09 AC 5 ms
4,380 KB
testcase_10 AC 4 ms
4,384 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 4 ms
4,384 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 5 ms
4,384 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 49 ms
7,640 KB
testcase_24 AC 40 ms
6,856 KB
testcase_25 AC 44 ms
7,372 KB
testcase_26 AC 42 ms
7,104 KB
testcase_27 AC 152 ms
12,376 KB
testcase_28 AC 41 ms
6,200 KB
testcase_29 AC 142 ms
11,916 KB
testcase_30 AC 87 ms
8,988 KB
testcase_31 AC 153 ms
12,820 KB
testcase_32 AC 179 ms
14,220 KB
testcase_33 AC 87 ms
8,868 KB
testcase_34 AC 101 ms
9,788 KB
testcase_35 AC 124 ms
11,204 KB
testcase_36 AC 84 ms
8,812 KB
testcase_37 AC 2 ms
4,384 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 199 ms
13,324 KB
testcase_40 AC 38 ms
5,980 KB
testcase_41 AC 42 ms
6,388 KB
testcase_42 AC 147 ms
11,656 KB
testcase_43 AC 57 ms
7,000 KB
testcase_44 AC 112 ms
9,808 KB
testcase_45 AC 56 ms
7,068 KB
testcase_46 AC 32 ms
5,700 KB
testcase_47 AC 211 ms
14,428 KB
testcase_48 AC 210 ms
14,320 KB
testcase_49 AC 213 ms
14,316 KB
testcase_50 AC 213 ms
14,304 KB
testcase_51 AC 221 ms
14,324 KB
testcase_52 AC 97 ms
11,136 KB
testcase_53 AC 133 ms
14,216 KB
testcase_54 AC 1 ms
4,380 KB
testcase_55 AC 1 ms
4,380 KB
testcase_56 AC 1 ms
4,380 KB
testcase_57 AC 47 ms
7,144 KB
testcase_58 AC 83 ms
9,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
int n; ll l;
ll x[100001], y[100001];
int main()
{
    cin>>n>>l;
    set<ll> stx, sty;
    for(int i=0; i<n; i++){
        cin>>x[i]; stx.insert(x[i]);
    }
    for(int i=0; i<n; i++){
        cin>>y[i]; sty.insert(y[i]);
    }
    ll r=0;
    int ct=0;
    while(!stx.empty() && !sty.empty()){
        auto itrx=stx.lower_bound(r);
        if(itrx==stx.end()){
            ct++;
            r=*stx.begin();
        }else{
            r=*itrx;
        }
        stx.erase(r);
        if(stx.empty()){
            if(r>*sty.begin()) ct++;
            r=*sty.begin();
            sty.erase(sty.begin());
            break;
        }
        ll r2;
        auto itry=sty.lower_bound(r);
        if(itry==sty.end()) r2=*sty.begin();
        else r2=*itry;
        itrx=stx.lower_bound(r2);
        ll r1;
        if(itrx==stx.end()) r1=*stx.begin();
        else r1=*itrx;
        itry=sty.lower_bound(r1);
        if(itry==sty.begin()){
            itry=sty.end(); itry--;
        }else{
            itry--;
        }
        if(*itry<r) ct++;
        r=*itry;
        sty.erase(itry);
    }
    ll ans=(ll)ct*l+r;
    cout<<ans<<endl;
    return 0;
}
0