結果
| 問題 | No.2566 美しい整数列 |
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2023-12-02 16:27:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 759 bytes |
| 記録 | |
| コンパイル時間 | 2,175 ms |
| コンパイル使用メモリ | 202,560 KB |
| 最終ジャッジ日時 | 2025-02-18 05:25:45 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 1 TLE * 1 -- * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "settings/debug.cpp"
#define _GLIBCXX_DEBUG
#else
#define Debug(...) void(0)
#endif
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)
int main() {
int n, m;
cin >> n >> m;
vector<int> a(n), b(m), c(n);
rep(i, n) cin >> a[i];
rep(i, m) cin >> b[i];
rep(i, n) cin >> c[i];
vector<ll> ideal_a(1, 0);
rep(i, n - 1) ideal_a.push_back(ideal_a.back() + b[i % m]);
Debug(ideal_a);
// greedy
unordered_set<ll> cand;
rep(i, n) cand.insert(a[i] - ideal_a[i]);
ll ans = 1e18;
for (ll a0 : cand) {
ll sum = 0;
rep(i, n) {
if (a0 + ideal_a[i] != a[i]) sum += c[i];
}
ans = min(ans, sum);
}
cout << ans << endl;
return 0;
}
a01sa01to