結果

問題 No.2566 美しい整数列
ユーザー ja14378ja14378
提出日時 2023-12-02 16:23:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 802 bytes
コンパイル時間 4,402 ms
コンパイル使用メモリ 269,120 KB
実行使用メモリ 20,608 KB
最終ジャッジ日時 2023-12-02 16:23:31
合計ジャッジ時間 8,466 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 145 ms
20,608 KB
testcase_05 AC 146 ms
20,608 KB
testcase_06 AC 73 ms
8,064 KB
testcase_07 AC 74 ms
8,064 KB
testcase_08 AC 73 ms
8,064 KB
testcase_09 AC 75 ms
8,064 KB
testcase_10 AC 75 ms
8,064 KB
testcase_11 AC 98 ms
11,136 KB
testcase_12 AC 96 ms
11,136 KB
testcase_13 AC 97 ms
11,136 KB
testcase_14 AC 97 ms
11,136 KB
testcase_15 AC 95 ms
11,136 KB
testcase_16 AC 151 ms
19,712 KB
testcase_17 AC 130 ms
19,968 KB
testcase_18 AC 134 ms
20,096 KB
testcase_19 AC 87 ms
14,464 KB
testcase_20 AC 119 ms
18,816 KB
testcase_21 AC 128 ms
19,200 KB
testcase_22 AC 82 ms
13,440 KB
testcase_23 AC 108 ms
17,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using ll = long long;
#define MOD 1000000007
#define Mod 998244353
const int MAX = 1000000005;
const long long INF = 1000000000000000005LL;
using namespace std;
using namespace atcoder;



int main() {
    ios::sync_with_stdio(0);cin.tie();
    int N, M;
    cin >> N >> M;
    vector<ll> A(N), B(M), C(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];
    map<ll, ll> mp;
    ll total = 0;
    for (int i = 0; i < N; i++) {
        mp[A[i] - total] += C[i];
        total += B[i % M];
    }
    ll sum = 0, ans = INF;
    for (int i = 0; i < N; i++) sum += C[i];
    for (auto [key, val] : mp) {
        ans = min(ans, sum - val);
    }
    cout << ans << endl;
}
0