結果

問題 No.808 Kaiten Sushi?
ユーザー face4face4
提出日時 2019-03-22 22:33:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,231 bytes
コンパイル時間 651 ms
コンパイル使用メモリ 74,096 KB
実行使用メモリ 12,972 KB
最終ジャッジ日時 2023-10-19 09:49:29
合計ジャッジ時間 6,444 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 6 ms
4,348 KB
testcase_10 AC 4 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 5 ms
4,348 KB
testcase_13 AC 4 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 6 ms
4,348 KB
testcase_16 AC 5 ms
4,348 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 57 ms
7,204 KB
testcase_24 AC 45 ms
6,492 KB
testcase_25 AC 50 ms
6,976 KB
testcase_26 AC 48 ms
6,792 KB
testcase_27 AC 167 ms
11,332 KB
testcase_28 AC 46 ms
5,964 KB
testcase_29 AC 157 ms
10,936 KB
testcase_30 AC 95 ms
8,380 KB
testcase_31 AC 176 ms
11,696 KB
testcase_32 AC 199 ms
12,776 KB
testcase_33 AC 96 ms
8,328 KB
testcase_34 AC 107 ms
9,064 KB
testcase_35 AC 135 ms
10,216 KB
testcase_36 AC 94 ms
8,244 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 211 ms
12,136 KB
testcase_40 WA -
testcase_41 AC 45 ms
5,924 KB
testcase_42 AC 169 ms
10,668 KB
testcase_43 AC 63 ms
6,692 KB
testcase_44 AC 120 ms
9,060 KB
testcase_45 AC 63 ms
6,700 KB
testcase_46 AC 34 ms
5,332 KB
testcase_47 AC 236 ms
12,972 KB
testcase_48 AC 230 ms
12,972 KB
testcase_49 AC 236 ms
12,972 KB
testcase_50 AC 233 ms
12,972 KB
testcase_51 AC 242 ms
12,972 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 2 ms
4,348 KB
testcase_56 AC 2 ms
4,348 KB
testcase_57 WA -
testcase_58 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
using namespace std;
typedef long long ll;

int main(){
    int n, l;
    cin >> n >> l;
    set<int> s[2];
    int in;
    for(int i = 0; i < n; i++)  cin >> in, s[0].insert(in);
    for(int i = 0; i < n; i++)  cin >> in, s[1].insert(in);
    ll ans = 0;
    int take = *(s[0].begin()), turn = 0;
    s[0].erase(s[0].begin());
    while(!s[0].empty() || !s[1].empty()){
        auto its = s[turn].upper_bound(take);
        auto itt = s[1-turn].upper_bound(take);
        if(its == s[turn].end())    its = s[turn].begin();
        if(itt == s[1-turn].end())  itt = s[1-turn].begin();
        int su = *its, te = *itt;
        if(take > su)   su += l;
        if(take > te)   te += l;
        if(te > su){
            int ntake = *itt;
            s[1-turn].erase(itt);
            if(take > ntake)    ans += l;
            take = ntake;
        }else{
            auto it = s[1-turn].lower_bound(*its);
            if(it == s[1-turn].begin()) it = s[1-turn].end();
            it--;
            int ntake = *it;
            s[1-turn].erase(it);
            if(take > ntake)    ans += l;
            take = ntake;
        }
        turn = 1-turn;
    }
    cout << ans+take << endl;
    return 0;
}
0