結果

問題 No.2566 美しい整数列
ユーザー Preds1dentPreds1dent
提出日時 2023-12-02 16:16:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 325 ms / 2,000 ms
コード長 770 bytes
コンパイル時間 1,668 ms
コンパイル使用メモリ 110,056 KB
実行使用メモリ 20,480 KB
最終ジャッジ日時 2023-12-02 16:17:07
合計ジャッジ時間 7,966 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 1 ms
6,548 KB
testcase_03 AC 1 ms
6,548 KB
testcase_04 AC 288 ms
20,480 KB
testcase_05 AC 325 ms
20,480 KB
testcase_06 AC 189 ms
8,064 KB
testcase_07 AC 196 ms
8,064 KB
testcase_08 AC 190 ms
8,064 KB
testcase_09 AC 194 ms
8,064 KB
testcase_10 AC 192 ms
8,064 KB
testcase_11 AC 236 ms
11,136 KB
testcase_12 AC 216 ms
11,136 KB
testcase_13 AC 226 ms
11,136 KB
testcase_14 AC 213 ms
11,136 KB
testcase_15 AC 210 ms
11,136 KB
testcase_16 AC 233 ms
19,584 KB
testcase_17 AC 274 ms
19,840 KB
testcase_18 AC 265 ms
19,968 KB
testcase_19 AC 175 ms
14,464 KB
testcase_20 AC 231 ms
18,816 KB
testcase_21 AC 244 ms
19,200 KB
testcase_22 AC 153 ms
13,440 KB
testcase_23 AC 203 ms
17,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <queue>
using namespace std;
#define int long long
signed main() {
  int n, m; cin >> n >> m;
  vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> b(m); for (int i = 0; i < m; i++) cin >> b[i];
  vector<int> c(n); for (int i = 0; i < n; i++) cin >> c[i];
  map<int, int> mp;
  int s = b[0];
  mp[a[0]] -= c[0];
  for (int i = 1; i < n; i++) {
    // s + base == a[i]
    // base = a[i] - s;
    int base = a[i] - s;
    mp[base] -= c[i];
    s += b[i % m];
  }
  int ans = 1ll<<60;
  for (auto [k, v] : mp) {
    ans = min(ans, v);
  }
  for (int i = 0; i < n; i++) {
    ans += c[i];
  }
  cout << ans << endl;

}
0