結果
問題 | No.2566 美しい整数列 |
ユーザー | takumi152 |
提出日時 | 2023-12-02 15:51:28 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 133 ms / 2,000 ms |
コード長 | 1,065 bytes |
コンパイル時間 | 932 ms |
コンパイル使用メモリ | 112,216 KB |
実行使用メモリ | 27,964 KB |
最終ジャッジ日時 | 2023-12-02 15:51:35 |
合計ジャッジ時間 | 4,551 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,676 KB |
testcase_01 | AC | 2 ms
6,676 KB |
testcase_02 | AC | 2 ms
6,676 KB |
testcase_03 | AC | 1 ms
6,676 KB |
testcase_04 | AC | 109 ms
27,964 KB |
testcase_05 | AC | 112 ms
27,964 KB |
testcase_06 | AC | 62 ms
10,588 KB |
testcase_07 | AC | 64 ms
10,652 KB |
testcase_08 | AC | 62 ms
10,588 KB |
testcase_09 | AC | 65 ms
10,588 KB |
testcase_10 | AC | 64 ms
10,672 KB |
testcase_11 | AC | 89 ms
14,784 KB |
testcase_12 | AC | 83 ms
14,784 KB |
testcase_13 | AC | 77 ms
14,780 KB |
testcase_14 | AC | 80 ms
14,772 KB |
testcase_15 | AC | 80 ms
14,772 KB |
testcase_16 | AC | 128 ms
27,092 KB |
testcase_17 | AC | 131 ms
27,356 KB |
testcase_18 | AC | 133 ms
27,484 KB |
testcase_19 | AC | 81 ms
18,968 KB |
testcase_20 | AC | 123 ms
26,004 KB |
testcase_21 | AC | 124 ms
26,408 KB |
testcase_22 | AC | 73 ms
17,684 KB |
testcase_23 | AC | 100 ms
22,692 KB |
ソースコード
#include <iostream> #include <iomanip> #include <vector> #include <algorithm> #include <utility> #include <string> #include <queue> #include <stack> #include <deque> #include <unordered_set> #include <unordered_map> using namespace std; typedef long long int ll; typedef pair<int, int> Pii; const ll mod = 998244353; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; vector<ll> a(n), b(m), c(n); for (auto &x: a) cin >> x; for (auto &x: b) cin >> x; for (auto &x: c) cin >> x; vector<ll> diff(n); diff[0] = 0; for (int i = 1; i < n; i++) { diff[i] = diff[i - 1] + ((a[i] - a[i - 1]) - b[(i - 1) % m]); } unordered_map<ll, vector<int>> diff_group; for (int i = 0; i < n; i++) { diff_group[diff[i]].push_back(i); } ll cost_max = 0; for (int i = 0; i < n; i++) { cost_max += c[i]; } ll ans = (ll) 9e18; for (auto &[k, v]: diff_group) { ll cost = cost_max; for (auto &i: v) { cost -= c[i]; } ans = min(ans, cost); } cout << ans << endl; return 0; }