結果

問題 No.808 Kaiten Sushi?
ユーザー ei1333333ei1333333
提出日時 2019-03-22 22:21:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,009 bytes
コンパイル時間 3,657 ms
コンパイル使用メモリ 211,172 KB
実行使用メモリ 6,276 KB
最終ジャッジ日時 2023-10-19 09:41:47
合計ジャッジ時間 6,642 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 5 ms
4,348 KB
testcase_10 AC 4 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 4 ms
4,348 KB
testcase_13 AC 4 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 4 ms
4,348 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
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 45 ms
4,380 KB
testcase_24 AC 36 ms
4,348 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 114 ms
5,428 KB
testcase_33 AC 57 ms
4,380 KB
testcase_34 AC 63 ms
4,380 KB
testcase_35 AC 79 ms
5,428 KB
testcase_36 AC 56 ms
4,380 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 101 ms
5,428 KB
testcase_40 AC 23 ms
4,348 KB
testcase_41 AC 29 ms
4,348 KB
testcase_42 AC 86 ms
5,428 KB
testcase_43 AC 39 ms
4,380 KB
testcase_44 AC 64 ms
4,380 KB
testcase_45 AC 37 ms
4,380 KB
testcase_46 AC 23 ms
4,348 KB
testcase_47 AC 114 ms
5,428 KB
testcase_48 AC 111 ms
5,428 KB
testcase_49 AC 113 ms
5,428 KB
testcase_50 AC 113 ms
5,428 KB
testcase_51 AC 115 ms
5,428 KB
testcase_52 WA -
testcase_53 WA -
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 30 ms
4,424 KB
testcase_58 AC 52 ms
4,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

const int inf = 1 << 30;

int main() {
  int N, L;
  cin >> N >> L;
  vector< pair< int, int > > mp;
  for(int z = 0; z < 2; z++) {
    for(int i = 0; i < N; i++) {
      int p;
      cin >> p;
      mp.emplace_back(p, z);
    }
  }
  sort(begin(mp), end(mp));

  auto check = [&](int sz) {
    vector< int > st[2];
    int match_min = inf;
    for(auto &p : mp) {
      if(st[p.second ^ 1].empty()) {
        if(st[0].size() + st[1].size() <= sz) {
          st[p.second].emplace_back(p.first);
        } else {
          return make_pair(false, -1);
        }
      } else {
        st[p.second ^ 1].pop_back();
        st[p.second].emplace_back(p.first);
      }
    }
    if(st[1].empty()) return make_pair(true, L + match_min);
    return make_pair(true, st[1][0]);
  };
  int ok = N, ng = -1;
  while(ok - ng > 1) {
    int mid = (ok + ng) / 2;
    if(check(mid).first) ok = mid;
    else ng = mid;
  }
  cout << 1LL * ok * L + check(ok).second << endl;
}
0