結果

問題 No.808 Kaiten Sushi?
ユーザー betrue12betrue12
提出日時 2019-03-22 23:13:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,016 bytes
コンパイル時間 2,194 ms
コンパイル使用メモリ 209,560 KB
実行使用メモリ 9,756 KB
最終ジャッジ日時 2023-10-19 10:25:17
合計ジャッジ時間 6,314 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_10 AC 4 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 5 ms
4,348 KB
testcase_16 AC 4 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 38 ms
5,988 KB
testcase_24 AC 31 ms
4,820 KB
testcase_25 AC 34 ms
5,948 KB
testcase_26 AC 33 ms
5,916 KB
testcase_27 AC 95 ms
9,496 KB
testcase_28 AC 30 ms
4,732 KB
testcase_29 AC 89 ms
9,428 KB
testcase_30 AC 57 ms
6,184 KB
testcase_31 AC 99 ms
9,556 KB
testcase_32 AC 111 ms
9,736 KB
testcase_33 AC 58 ms
6,172 KB
testcase_34 AC 64 ms
6,296 KB
testcase_35 AC 79 ms
9,308 KB
testcase_36 AC 58 ms
6,160 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 104 ms
9,628 KB
testcase_40 AC 24 ms
4,684 KB
testcase_41 AC 30 ms
4,724 KB
testcase_42 AC 86 ms
9,384 KB
testcase_43 AC 40 ms
5,900 KB
testcase_44 AC 62 ms
6,296 KB
testcase_45 AC 37 ms
5,900 KB
testcase_46 AC 23 ms
4,628 KB
testcase_47 AC 115 ms
9,756 KB
testcase_48 AC 111 ms
9,756 KB
testcase_49 AC 116 ms
9,756 KB
testcase_50 AC 114 ms
9,756 KB
testcase_51 AC 116 ms
9,756 KB
testcase_52 AC 77 ms
9,316 KB
testcase_53 AC 104 ms
9,736 KB
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 AC 33 ms
5,928 KB
testcase_58 AC 59 ms
6,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    int N;
    int64_t L, X[100000], Y[100000];
    cin >> N >> L;
    for(int i=0; i<N; i++) cin >> X[i];
    for(int i=0; i<N; i++) cin >> Y[i];

    vector<pair<int64_t, int64_t>> order;
    for(int i=0; i<N; i++){
        order.push_back({X[i], 1});
        order.push_back({Y[i], -1});
    }
    sort(order.begin(), order.end());

    int mn = 0, now = 0;
    for(auto& p : order){
        now += p.second;
        mn = min(mn, now);
    }
    mn *= -1;

    order.clear();
    for(int i=0; i<N; i++){
        order.push_back({X[i], 1});
        if(i < mn){
            order.push_back({Y[i]+L, -1});
        }else{
            order.push_back({Y[i], -1});
        }
    }
    sort(order.begin(), order.end());
    int64_t ans = 0;
    now = 0;
    for(auto& p : order){
        if(p.second == 1){
            now++;
        }else{
            now--;
            ans = max(ans, now*L + p.first);
        }
    }
    cout << ans << endl;
    return 0;
}
0