結果

問題 No.2566 美しい整数列
ユーザー GOTKAKOGOTKAKO
提出日時 2023-12-02 15:35:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 711 bytes
コンパイル時間 2,228 ms
コンパイル使用メモリ 214,328 KB
実行使用メモリ 29,952 KB
最終ジャッジ日時 2023-12-02 15:36:08
合計ジャッジ時間 6,331 ms
ジャッジサーバーID
(参考情報)
judge10 / 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 AC 159 ms
29,952 KB
testcase_05 AC 157 ms
29,952 KB
testcase_06 AC 69 ms
9,288 KB
testcase_07 AC 71 ms
9,344 KB
testcase_08 AC 69 ms
9,288 KB
testcase_09 AC 70 ms
9,288 KB
testcase_10 AC 71 ms
9,364 KB
testcase_11 AC 104 ms
14,300 KB
testcase_12 AC 102 ms
14,296 KB
testcase_13 AC 101 ms
14,300 KB
testcase_14 AC 101 ms
14,304 KB
testcase_15 AC 100 ms
14,300 KB
testcase_16 AC 159 ms
29,056 KB
testcase_17 AC 166 ms
29,312 KB
testcase_18 AC 192 ms
29,440 KB
testcase_19 AC 115 ms
20,736 KB
testcase_20 AC 156 ms
27,520 KB
testcase_21 AC 176 ms
28,160 KB
testcase_22 AC 114 ms
19,200 KB
testcase_23 AC 129 ms
25,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

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

    int N,M; cin >> N >> M;
    long long sumc = 0;
    vector<long long> A(N),B(M),C(N);
    for(auto &a : A) cin >> a;
    for(auto &b : B) cin >> b;
    for(auto &c : C) cin >> c,sumc += c;

    map<long long,vector<int>> S;
    long long now = A.at(0);
    S[0].push_back(0);
    for(int i=1; i<N; i++){
        now += B.at((i-1)%M);
        S[now-A.at(i)].push_back(i);
    }

    long long answer = sumc;
    for(auto[diff,D] : S){
        long long nowcost = 0;
        for(auto d : D) nowcost += C.at(d);
        answer = min(sumc-nowcost,answer);
    }
    cout << answer << endl;
}
0