結果

問題 No.2566 美しい整数列
ユーザー eve__fuyukieve__fuyuki
提出日時 2023-12-11 12:44:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 788 bytes
コンパイル時間 2,398 ms
コンパイル使用メモリ 211,120 KB
実行使用メモリ 22,144 KB
最終ジャッジ日時 2023-12-11 12:44:15
合計ジャッジ時間 8,313 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 134 ms
22,144 KB
testcase_05 AC 133 ms
22,144 KB
testcase_06 AC 63 ms
9,600 KB
testcase_07 AC 65 ms
9,600 KB
testcase_08 AC 64 ms
9,600 KB
testcase_09 AC 67 ms
9,600 KB
testcase_10 AC 68 ms
9,600 KB
testcase_11 AC 85 ms
12,800 KB
testcase_12 AC 88 ms
12,800 KB
testcase_13 AC 85 ms
12,800 KB
testcase_14 AC 81 ms
12,800 KB
testcase_15 AC 94 ms
12,800 KB
testcase_16 AC 112 ms
21,248 KB
testcase_17 AC 121 ms
21,504 KB
testcase_18 AC 136 ms
21,632 KB
testcase_19 AC 81 ms
15,488 KB
testcase_20 AC 109 ms
20,224 KB
testcase_21 AC 122 ms
20,736 KB
testcase_22 AC 84 ms
14,464 KB
testcase_23 AC 100 ms
18,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    fast_io();
    int n, m;
    cin >> n >> m;
    vector<long long> a(n), b(m), c(n);
    long long ans = 0;
    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];
        ans += c[i];
    }
    vector<long long> d(n);
    for (int i = 0; i < n - 1; i++) {
        d[i + 1] = d[i] + b[i % m];
    }
    map<long long, long long> mp;
    for (int i = 0; i < n; i++) {
        mp[d[i] - a[i]] += c[i];
    }
    long long ma = 0;
    for (auto [k, v] : mp) {
        ma = max(v, ma);
    }
    ans -= ma;
    cout << ans << endl;
}
0