結果
問題 | No.2566 美しい整数列 |
ユーザー |
![]() |
提出日時 | 2023-12-02 16:40:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 374 ms / 2,000 ms |
コード長 | 738 bytes |
コンパイル時間 | 2,172 ms |
コンパイル使用メモリ | 201,620 KB |
最終ジャッジ日時 | 2025-02-18 05:36:05 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h>using namespace std;#ifdef LOCAL#include "settings/debug.cpp"#define _GLIBCXX_DEBUG#else#define Debug(...) void(0)#endifusing 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;}