結果

問題 No.2566 美しい整数列
ユーザー yansi819yansi819
提出日時 2024-04-05 08:52:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 337 ms / 2,000 ms
コード長 700 bytes
コンパイル時間 4,299 ms
コンパイル使用メモリ 269,008 KB
実行使用メモリ 22,144 KB
最終ジャッジ日時 2024-04-05 08:52:43
合計ジャッジ時間 11,252 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
6,676 KB
testcase_04 AC 320 ms
22,144 KB
testcase_05 AC 337 ms
22,144 KB
testcase_06 AC 208 ms
9,600 KB
testcase_07 AC 215 ms
9,600 KB
testcase_08 AC 211 ms
9,600 KB
testcase_09 AC 214 ms
9,600 KB
testcase_10 AC 217 ms
9,600 KB
testcase_11 AC 242 ms
12,672 KB
testcase_12 AC 240 ms
12,672 KB
testcase_13 AC 239 ms
12,672 KB
testcase_14 AC 236 ms
12,672 KB
testcase_15 AC 237 ms
12,672 KB
testcase_16 AC 276 ms
21,248 KB
testcase_17 AC 293 ms
21,504 KB
testcase_18 AC 295 ms
21,632 KB
testcase_19 AC 190 ms
15,488 KB
testcase_20 AC 265 ms
20,224 KB
testcase_21 AC 276 ms
20,608 KB
testcase_22 AC 172 ms
14,464 KB
testcase_23 AC 220 ms
18,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;

int main() {
  int N, M; cin >> N >> M;
  vector<ll> A(N), B(M), C(N), sum(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < M; i++) cin >> B[i];
  for (int i = 0; i < N; i++) cin >> C[i];
  for (int i = 0; i < N - 1; i++) sum[i + 1] = sum[i] + B[i % M];
  ll cost_all = 0;
  for (int i = 0; i < N; i++) cost_all += C[i];
  map<ll, ll> mp;
  for (int i = 0; i < N; i++) mp[A[i] - sum[i]] += C[i];
  ll ans = cost_all;
  for (auto p: mp) ans = min(ans, cost_all - p.second);
  cout << ans << endl;
  return 0;
}
0