結果
問題 | No.2566 美しい整数列 |
ユーザー |
|
提出日時 | 2023-11-23 16:17:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 152 ms / 2,000 ms |
コード長 | 684 bytes |
コンパイル時間 | 2,076 ms |
コンパイル使用メモリ | 201,860 KB |
最終ジャッジ日時 | 2025-02-17 23:22:31 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h>#define rep(i,n) for(int i=0;i<(n);++i)using namespace std;using ll = long long;int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int n,m;cin >> n >> m;vector<ll>a(n),b(n-1),c(n);rep(i,n) cin >> a[i];rep(i,m) cin >> b[i];rep(i,n) cin >> c[i];rep(i,n-1) b[i] = b[i%m];vector<ll> d(n,0);rep(i,n-1) d[i+1] += d[i]+b[i];vector<ll> e(n,0);rep(i,n){e[i] = d[i]-a[i];}map<ll,ll> mp;rep(i,n) mp[e[i]]+=c[i];ll sum = 0;rep(i,n) sum += c[i];ll ans = 1e18;for(auto [x,y]:mp){ans = min(ans,sum-y);}cout << ans << endl;}