結果

問題 No.808 Kaiten Sushi?
ユーザー ei1333333ei1333333
提出日時 2019-03-22 23:26:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 1,122 bytes
コンパイル時間 2,300 ms
コンパイル使用メモリ 208,764 KB
実行使用メモリ 7,728 KB
最終ジャッジ日時 2023-10-19 10:48:24
合計ジャッジ時間 5,849 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 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 4 ms
4,348 KB
testcase_10 AC 4 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 4 ms
4,348 KB
testcase_16 AC 4 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 3 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 35 ms
4,940 KB
testcase_24 AC 28 ms
4,428 KB
testcase_25 AC 30 ms
4,900 KB
testcase_26 AC 30 ms
4,868 KB
testcase_27 AC 74 ms
6,676 KB
testcase_28 AC 24 ms
4,348 KB
testcase_29 AC 71 ms
6,604 KB
testcase_30 AC 44 ms
5,132 KB
testcase_31 AC 78 ms
6,732 KB
testcase_32 AC 88 ms
6,916 KB
testcase_33 AC 44 ms
5,124 KB
testcase_34 AC 49 ms
5,244 KB
testcase_35 AC 61 ms
6,484 KB
testcase_36 AC 45 ms
5,108 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 79 ms
6,804 KB
testcase_40 AC 19 ms
4,348 KB
testcase_41 AC 23 ms
4,348 KB
testcase_42 AC 67 ms
6,564 KB
testcase_43 AC 31 ms
4,852 KB
testcase_44 AC 51 ms
5,244 KB
testcase_45 AC 31 ms
4,852 KB
testcase_46 AC 18 ms
4,348 KB
testcase_47 AC 88 ms
6,948 KB
testcase_48 AC 88 ms
6,948 KB
testcase_49 AC 89 ms
6,948 KB
testcase_50 AC 89 ms
6,948 KB
testcase_51 AC 88 ms
6,948 KB
testcase_52 AC 65 ms
6,512 KB
testcase_53 AC 86 ms
7,728 KB
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 27 ms
4,904 KB
testcase_58 AC 47 ms
5,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;

int main() {
  int N, L;
  cin >> N >> L;
  vector< pair< int, int > > mp2[2], mp;
  for(int z = 0; z < 2; z++) {
    for(int i = 0; i < N; i++) {
      int p;
      cin >> p;
      mp2[z].emplace_back(p, z);
    }
  }
  std::merge(mp2[0].begin(), mp2[0].end(),
             mp2[1].begin(), mp2[1].end(),
             std::back_inserter(mp));

  vector< int > st[2];
  int match_min = inf;
  for(auto &p : mp) {
    if(p.second == 0) {
      if(st[1].empty()) {
        st[p.second].emplace_back(p.first);
        continue;
      }
      st[1].pop_back();
      st[0].emplace_back(p.first);
    } else {
      if(st[0].empty()) {
        match_min = min(match_min, p.first);
        st[p.second].emplace_back(p.first);
        continue;
      }
      st[0].pop_back();
      st[1].emplace_back(p.first);
    }
  }
  if(st[1].empty()) cout << 1LL * L * (st[0].size() + st[1].size() - 1) + L + match_min << endl;
  else cout << 1LL * L * (st[0].size() + st[1].size() - 1) + st[1][0] << endl;
}

0