結果

問題 No.2566 美しい整数列
ユーザー a01sa01toa01sa01to
提出日時 2023-12-02 16:40:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 334 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 2,232 ms
コンパイル使用メモリ 211,384 KB
実行使用メモリ 22,144 KB
最終ジャッジ日時 2023-12-02 16:40:11
合計ジャッジ時間 9,162 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 3 ms
6,548 KB
testcase_04 AC 324 ms
22,144 KB
testcase_05 AC 334 ms
22,144 KB
testcase_06 AC 208 ms
9,600 KB
testcase_07 AC 240 ms
9,600 KB
testcase_08 AC 210 ms
9,600 KB
testcase_09 AC 213 ms
9,600 KB
testcase_10 AC 216 ms
9,600 KB
testcase_11 AC 235 ms
12,672 KB
testcase_12 AC 239 ms
12,672 KB
testcase_13 AC 236 ms
12,672 KB
testcase_14 AC 238 ms
12,672 KB
testcase_15 AC 238 ms
12,672 KB
testcase_16 AC 270 ms
21,248 KB
testcase_17 AC 286 ms
21,504 KB
testcase_18 AC 298 ms
21,632 KB
testcase_19 AC 198 ms
15,488 KB
testcase_20 AC 264 ms
20,224 KB
testcase_21 AC 284 ms
20,608 KB
testcase_22 AC 179 ms
14,464 KB
testcase_23 AC 227 ms
18,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
  #define _GLIBCXX_DEBUG
#else
  #define Debug(...) void(0)
#endif
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> a(n), b(m), c(n);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  rep(i, n) cin >> c[i];
  vector<ll> ideal_a(n, 0);
  rep(i, n - 1) ideal_a[i + 1] = ideal_a[i] + b[i % m];
  map<ll, ll> cnt;
  rep(i, n) {
    ll x = a[i] - ideal_a[i];
    cnt[x] += c[i];
  }
  ll ans = accumulate(c.begin(), c.end(), 0LL);
  ans -= max_element(cnt.begin(), cnt.end(), [](auto a, auto b) { return a.second < b.second; })->second;
  cout << ans << endl;
  return 0;
}
0