結果
| 問題 |
No.808 Kaiten Sushi?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-22 23:13:52 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,016 bytes |
| コンパイル時間 | 1,896 ms |
| コンパイル使用メモリ | 200,196 KB |
| 最終ジャッジ日時 | 2025-01-07 00:03:58 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 49 WA * 7 |
ソースコード
#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;
}