結果
| 問題 |
No.808 Kaiten Sushi?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-31 20:25:07 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 107 ms / 2,000 ms |
| コード長 | 891 bytes |
| コンパイル時間 | 1,460 ms |
| コンパイル使用メモリ | 165,276 KB |
| 実行使用メモリ | 7,168 KB |
| 最終ジャッジ日時 | 2024-11-22 08:23:13 |
| 合計ジャッジ時間 | 6,687 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 56 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
int first;
int second;
int third;
}T;
//昇順
bool comp_Se(T& l, T& r){
return l.second < r.second;
}
int main(void){
int N;
ll L;
cin >> N >> L;
vector<pair<ll,int> > v(2*N);
int i;
REP(i,N){
cin >> v[i].first;
v[i].second = 0;
}
REP(i,N){
cin >> v[N+i].first;
v[N+i].second = 1;
}
sort(v.begin(),v.end());
int index;
ll count=0,max=0,min=0;
pair<int,int> p;
vector<int> d(v.size());
REP(i,v.size()){
if(!v[i].second)count++;
else count--;
if(count >= max){
max = count;
index = i;
}
if(count < min) min = count;
}
ll ans;
if(max>0) ans = (max-min-1)*L + v[index+1].first;
else ans = (max-min)*L + v[0].first;
cout << ans << endl;
return 0;
}