結果

問題 No.2566 美しい整数列
ユーザー a01sa01toa01sa01to
提出日時 2023-12-02 16:27:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 759 bytes
コンパイル時間 2,229 ms
コンパイル使用メモリ 212,148 KB
実行使用メモリ 23,436 KB
最終ジャッジ日時 2023-12-02 16:27:12
合計ジャッジ時間 6,733 ms
ジャッジサーバーID
(参考情報)
judge13 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
6,676 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

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<int> 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(1, 0);
  rep(i, n - 1) ideal_a.push_back(ideal_a.back() + b[i % m]);
  Debug(ideal_a);
  // greedy
  unordered_set<ll> cand;
  rep(i, n) cand.insert(a[i] - ideal_a[i]);
  ll ans = 1e18;
  for (ll a0 : cand) {
    ll sum = 0;
    rep(i, n) {
      if (a0 + ideal_a[i] != a[i]) sum += c[i];
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
0