結果

問題 No.808 Kaiten Sushi?
ユーザー 48025254802525
提出日時 2019-03-31 20:25:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 891 bytes
コンパイル時間 1,484 ms
コンパイル使用メモリ 151,776 KB
実行使用メモリ 7,032 KB
最終ジャッジ日時 2023-08-14 11:39:44
合計ジャッジ時間 8,322 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,384 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 37 ms
4,576 KB
testcase_24 AC 30 ms
4,380 KB
testcase_25 AC 34 ms
4,384 KB
testcase_26 AC 33 ms
4,444 KB
testcase_27 AC 79 ms
6,092 KB
testcase_28 AC 25 ms
4,380 KB
testcase_29 AC 75 ms
6,152 KB
testcase_30 AC 47 ms
5,428 KB
testcase_31 AC 84 ms
6,556 KB
testcase_32 AC 96 ms
6,764 KB
testcase_33 AC 48 ms
4,808 KB
testcase_34 AC 53 ms
5,492 KB
testcase_35 AC 66 ms
5,728 KB
testcase_36 AC 47 ms
5,120 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 85 ms
6,752 KB
testcase_40 AC 20 ms
4,380 KB
testcase_41 AC 24 ms
4,380 KB
testcase_42 AC 72 ms
5,936 KB
testcase_43 AC 32 ms
4,384 KB
testcase_44 AC 56 ms
5,332 KB
testcase_45 AC 32 ms
4,380 KB
testcase_46 AC 19 ms
4,380 KB
testcase_47 AC 96 ms
7,020 KB
testcase_48 AC 95 ms
6,884 KB
testcase_49 AC 94 ms
6,980 KB
testcase_50 AC 96 ms
7,032 KB
testcase_51 AC 96 ms
6,948 KB
testcase_52 AC 58 ms
5,704 KB
testcase_53 AC 78 ms
6,940 KB
testcase_54 AC 1 ms
4,380 KB
testcase_55 AC 2 ms
4,376 KB
testcase_56 AC 1 ms
4,376 KB
testcase_57 AC 25 ms
4,384 KB
testcase_58 AC 44 ms
5,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0