結果

問題 No.808 Kaiten Sushi?
ユーザー betrue12
提出日時 2019-03-22 22:20:36
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 768 bytes
コンパイル時間 2,402 ms
コンパイル使用メモリ 203,824 KB
最終ジャッジ日時 2025-01-06 23:56:31
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38 WA * 18
権限があれば一括ダウンロードができます

ソースコード

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, int>> order;
    for(int i=0; i<N; i++){
        order.push_back({X[i], -1});
        if(Y[i] < X[0]){
            order.push_back({Y[i]+L, 1});
        }else{
            order.push_back({Y[i], 1});
        }
    }
    sort(order.rbegin(), order.rend());

    int64_t now = 0, mx = 0, pos = 0;
    for(auto& p : order){
        now += p.second;
        if(now < 0) now++;
        if(now > mx){
            mx = now;
            pos = p.first;
        }
    }
    int64_t ans = (mx-1) * L + pos;
    cout << ans << endl;
    return 0;
}
0