結果

問題 No.2566 美しい整数列
ユーザー inkyamaninkyaman
提出日時 2024-03-24 13:47:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 332 ms / 2,000 ms
コード長 952 bytes
コンパイル時間 1,358 ms
コンパイル使用メモリ 125,752 KB
実行使用メモリ 22,200 KB
最終ジャッジ日時 2024-03-24 13:47:23
合計ジャッジ時間 9,779 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,736 KB
testcase_01 AC 2 ms
7,736 KB
testcase_02 AC 2 ms
7,736 KB
testcase_03 AC 3 ms
7,736 KB
testcase_04 AC 319 ms
22,200 KB
testcase_05 AC 332 ms
22,200 KB
testcase_06 AC 230 ms
9,656 KB
testcase_07 AC 212 ms
9,656 KB
testcase_08 AC 206 ms
9,656 KB
testcase_09 AC 212 ms
9,656 KB
testcase_10 AC 210 ms
9,656 KB
testcase_11 AC 232 ms
12,728 KB
testcase_12 AC 246 ms
12,728 KB
testcase_13 AC 232 ms
12,728 KB
testcase_14 AC 233 ms
12,728 KB
testcase_15 AC 233 ms
12,728 KB
testcase_16 AC 263 ms
22,200 KB
testcase_17 AC 285 ms
22,200 KB
testcase_18 AC 289 ms
22,200 KB
testcase_19 AC 187 ms
17,464 KB
testcase_20 AC 254 ms
21,176 KB
testcase_21 AC 293 ms
21,432 KB
testcase_22 AC 170 ms
16,696 KB
testcase_23 AC 222 ms
20,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
#include <tuple>
using namespace std;
using ll = long long;

int N, M;
ll A[200009], B[200009];
ll C[200009];

int main() {
    
    cin >> N >> M;
    ll sum = 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];
        sum += C[i];
    }

    vector<ll> add(N,0);
    for(int i = 1; i < N; ++i) add[i] = add[i-1]+B[(i-1)%M];
    // for(int i = 0; i < N; ++i) cout << add[i] << endl;

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

    ll ans = 1e18;
    for(auto [k, v] : mp) ans = min(ans, sum-v);

    cout << ans << endl;

}
0