結果

問題 No.2566 美しい整数列
ユーザー t98slidert98slider
提出日時 2023-12-02 15:36:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 647 bytes
コンパイル時間 2,213 ms
コンパイル使用メモリ 212,856 KB
実行使用メモリ 20,608 KB
最終ジャッジ日時 2023-12-02 15:36:25
合計ジャッジ時間 5,905 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 136 ms
20,608 KB
testcase_05 AC 132 ms
20,608 KB
testcase_06 AC 63 ms
8,064 KB
testcase_07 AC 65 ms
8,064 KB
testcase_08 AC 64 ms
8,064 KB
testcase_09 AC 66 ms
8,064 KB
testcase_10 AC 63 ms
8,064 KB
testcase_11 AC 86 ms
11,136 KB
testcase_12 AC 91 ms
11,136 KB
testcase_13 AC 88 ms
11,136 KB
testcase_14 AC 86 ms
11,136 KB
testcase_15 AC 82 ms
11,136 KB
testcase_16 AC 114 ms
19,712 KB
testcase_17 AC 124 ms
19,968 KB
testcase_18 AC 127 ms
20,096 KB
testcase_19 AC 86 ms
14,464 KB
testcase_20 AC 114 ms
18,816 KB
testcase_21 AC 127 ms
19,200 KB
testcase_22 AC 78 ms
13,440 KB
testcase_23 AC 99 ms
17,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<class T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<ll> a(n), b(m), c(n);
    cin >> a >> b >> c;
    ll s = 0, ans = 1ll << 60;
    map<ll, ll> mp;
    mp[a[0]] += c[0];
    for(int i = 1; i < n; i++){
        s += b[(i - 1) % m];
        mp[a[i] - s] += c[i];
    }
    s = accumulate(c.begin(), c.end(), 0ll);
    for(auto &&[key, v] : mp){
        ans = min(ans, s - v);
    }
    cout << ans << '\n';
}
0