結果

問題 No.2603 Tone Correction
ユーザー 👑 amentorimaruamentorimaru
提出日時 2023-11-23 21:24:58
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 180 ms / 2,000 ms
コード長 633 bytes
コンパイル時間 1,031 ms
コンパイル使用メモリ 100,840 KB
実行使用メモリ 9,348 KB
最終ジャッジ日時 2024-01-12 20:50:34
合計ジャッジ時間 6,286 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 4 ms
6,676 KB
testcase_04 AC 5 ms
6,676 KB
testcase_05 AC 4 ms
6,676 KB
testcase_06 AC 4 ms
6,676 KB
testcase_07 AC 4 ms
6,676 KB
testcase_08 AC 4 ms
6,676 KB
testcase_09 AC 5 ms
6,676 KB
testcase_10 AC 4 ms
6,676 KB
testcase_11 AC 5 ms
6,676 KB
testcase_12 AC 4 ms
6,676 KB
testcase_13 AC 178 ms
9,348 KB
testcase_14 AC 176 ms
9,348 KB
testcase_15 AC 178 ms
9,348 KB
testcase_16 AC 177 ms
9,348 KB
testcase_17 AC 178 ms
9,348 KB
testcase_18 AC 176 ms
9,348 KB
testcase_19 AC 176 ms
9,348 KB
testcase_20 AC 177 ms
9,348 KB
testcase_21 AC 180 ms
9,348 KB
testcase_22 AC 180 ms
9,348 KB
testcase_23 AC 129 ms
9,348 KB
testcase_24 AC 128 ms
9,348 KB
testcase_25 AC 129 ms
9,348 KB
testcase_26 AC 129 ms
9,348 KB
testcase_27 AC 130 ms
9,348 KB
testcase_28 AC 127 ms
9,348 KB
testcase_29 AC 135 ms
9,348 KB
testcase_30 AC 129 ms
9,348 KB
testcase_31 AC 130 ms
9,348 KB
testcase_32 AC 131 ms
9,348 KB
testcase_33 AC 2 ms
6,676 KB
testcase_34 AC 167 ms
9,348 KB
testcase_35 AC 166 ms
9,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n), b(n);
  for (ll i = 0; i < n; i++)
    cin >> a[i];
  for (ll i = 0; i < n; i++) {
    cin >> b[i];
    b[i] += m - a[i];
    b[i] %= m;
  }
  b.insert(b.begin(), 0);
  b.push_back(0);
  vector<ll> db(n + 1);
  ll plus = 0;
  for (ll i = 0; i < n + 1; i++) {
    db[i] = (m + b[i + 1] - b[i]) % m;
    plus += b[i + 1] >= b[i];
  }
  ll ans = 0;
  sort(db.begin(), db.end());
  for (ll i = 0; i < plus; i++) {
    ans += db[i];
  }
  cout << ans << endl;
  return 0;
}

0