結果

問題 No.2566 美しい整数列
ユーザー momoyuumomoyuu
提出日時 2023-12-15 14:37:05
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 670 bytes
コンパイル時間 1,227 ms
コンパイル使用メモリ 111,420 KB
実行使用メモリ 20,608 KB
最終ジャッジ日時 2023-12-15 14:37:13
合計ジャッジ時間 7,491 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 135 ms
20,608 KB
testcase_05 AC 146 ms
20,608 KB
testcase_06 AC 68 ms
8,064 KB
testcase_07 AC 68 ms
8,064 KB
testcase_08 AC 66 ms
8,064 KB
testcase_09 AC 68 ms
8,064 KB
testcase_10 AC 69 ms
8,064 KB
testcase_11 AC 93 ms
11,136 KB
testcase_12 AC 93 ms
11,136 KB
testcase_13 AC 93 ms
11,136 KB
testcase_14 AC 94 ms
11,136 KB
testcase_15 AC 93 ms
11,136 KB
testcase_16 AC 133 ms
19,712 KB
testcase_17 AC 139 ms
19,968 KB
testcase_18 AC 150 ms
20,096 KB
testcase_19 AC 98 ms
14,464 KB
testcase_20 AC 127 ms
18,816 KB
testcase_21 AC 143 ms
19,200 KB
testcase_22 AC 92 ms
13,440 KB
testcase_23 AC 104 ms
17,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;

#include<map>
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    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];
    ll sum = 0;
    for(int i = 0;i<n;i++) sum += c[i];
    ll ans = sum;
    map<ll,ll> memo;
    ll tmp = 0;
    for(int i = 0;i<n;i++){
        if(i>0){
            tmp += b[(i-1) % m];
        }
        memo[a[i]-tmp] += c[i];
    }
    for(auto&itr:memo) ans = min(ans,sum-itr.second);
    cout<<ans<<endl;
}
0