結果

問題 No.2566 美しい整数列
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-12-09 00:14:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 3,006 ms
コンパイル使用メモリ 211,120 KB
実行使用メモリ 22,144 KB
最終ジャッジ日時 2023-12-09 00:14:14
合計ジャッジ時間 9,491 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 138 ms
22,144 KB
testcase_05 AC 143 ms
22,144 KB
testcase_06 AC 69 ms
9,600 KB
testcase_07 AC 69 ms
9,600 KB
testcase_08 AC 68 ms
9,600 KB
testcase_09 AC 70 ms
9,600 KB
testcase_10 AC 70 ms
9,600 KB
testcase_11 AC 92 ms
12,800 KB
testcase_12 AC 92 ms
12,800 KB
testcase_13 AC 95 ms
12,800 KB
testcase_14 AC 94 ms
12,800 KB
testcase_15 AC 92 ms
12,800 KB
testcase_16 AC 134 ms
21,248 KB
testcase_17 AC 144 ms
21,504 KB
testcase_18 AC 147 ms
21,632 KB
testcase_19 AC 96 ms
15,488 KB
testcase_20 AC 126 ms
20,224 KB
testcase_21 AC 178 ms
20,736 KB
testcase_22 AC 86 ms
14,464 KB
testcase_23 AC 104 ms
18,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    ll N, M, sm=0, ans=1e18;
    cin >> N >> M;
    vector<ll> A(N), B(M), C(N), S(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++){
        S[i+1] = S[i] + B[i % M];
    }

    map<ll, ll> mp;
    for (int i=0; i<N; i++){
        mp[A[i]-S[i]] += C[i];
        sm += C[i];
    }

    for (auto [x, y] : mp){
        ans = min(ans, sm-y);
    }

    cout << ans << endl;

    return 0;
}
0