結果

問題 No.808 Kaiten Sushi?
ユーザー pekempeypekempey
提出日時 2019-03-22 22:45:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 976 bytes
コンパイル時間 815 ms
コンパイル使用メモリ 81,648 KB
実行使用メモリ 23,704 KB
最終ジャッジ日時 2023-10-19 09:57:18
合計ジャッジ時間 9,510 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 4 ms
4,348 KB
testcase_08 AC 4 ms
4,348 KB
testcase_09 AC 8 ms
4,348 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 6 ms
4,348 KB
testcase_13 AC 5 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 7 ms
4,348 KB
testcase_16 WA -
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 102 ms
11,296 KB
testcase_24 AC 81 ms
9,712 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 328 ms
23,176 KB
testcase_33 AC 155 ms
13,672 KB
testcase_34 AC 182 ms
15,256 KB
testcase_35 AC 227 ms
17,632 KB
testcase_36 AC 152 ms
13,408 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 WA -
testcase_39 AC 370 ms
21,856 KB
testcase_40 AC 69 ms
7,884 KB
testcase_41 AC 74 ms
8,392 KB
testcase_42 AC 298 ms
18,688 KB
testcase_43 AC 105 ms
9,976 KB
testcase_44 AC 228 ms
15,256 KB
testcase_45 AC 105 ms
9,976 KB
testcase_46 AC 54 ms
7,188 KB
testcase_47 AC 436 ms
23,704 KB
testcase_48 AC 456 ms
23,704 KB
testcase_49 AC 439 ms
23,704 KB
testcase_50 AC 449 ms
23,704 KB
testcase_51 AC 457 ms
23,704 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 83 ms
10,504 KB
testcase_58 AC 139 ms
14,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>

using namespace std;

int main() {
  int N;
  long long L;
  cin >> N >> L;
  vector<long long> A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  set<long long> a, b;
  for (int i = 0; i < N; i++) {
    a.insert(A[i]);
    a.insert(A[i] + L);
    b.insert(B[i]);
    b.insert(B[i] + L);
  }
  long long ans = 0;
  long long x = 0;
  for (int i = 0; i < N; i++) {
    {
      auto it = b.lower_bound(x);
      auto it2 = prev(a.lower_bound(*it));
      ans += *it2 - x;
      x = *it2 % L;
      a.erase(x);
      a.erase(x + L);
    }
    {
      if (!a.empty()) {
        auto it = a.lower_bound(x);
        auto it2 = prev(b.lower_bound(*it));
        ans += *it2 - x;
        x = *it2 % L;
        b.erase(x);
        b.erase(x + L);
      } else {
        ans += *b.lower_bound(x) - x;
      }
    }
  }
  cout << ans << '\n';
}
0