結果

問題 No.808 Kaiten Sushi?
ユーザー face4face4
提出日時 2019-03-22 23:19:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,643 bytes
コンパイル時間 773 ms
コンパイル使用メモリ 73,436 KB
実行使用メモリ 12,944 KB
最終ジャッジ日時 2023-10-19 10:45:32
合計ジャッジ時間 5,770 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 4 ms
4,348 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 3 ms
4,348 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 3 ms
4,348 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 55 ms
7,176 KB
testcase_24 AC 45 ms
6,464 KB
testcase_25 AC 49 ms
6,948 KB
testcase_26 AC 48 ms
6,764 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 107 ms
10,236 KB
testcase_53 AC 149 ms
12,740 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 2 ms
4,348 KB
testcase_56 WA -
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);
        int add = 0;
        if(its == s[turn].end())    its = s[turn].begin(), add = l;
        auto itt = s[1-turn].upper_bound(*its+add);
        if(itt != s[1-turn].begin())  itt--;
        int ntake = *itt;
        s[1-turn].erase(itt);
        if(take > ntake)    ans += l;
        take = ntake;

        // 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