結果

問題 No.1618 Convolution?
ユーザー Kenshin2438Kenshin2438
提出日時 2022-09-24 16:30:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 849 bytes
コンパイル時間 1,507 ms
コンパイル使用メモリ 166,664 KB
実行使用メモリ 7,960 KB
最終ジャッジ日時 2023-08-24 00:26:14
合計ジャッジ時間 8,617 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 43 ms
6,788 KB
testcase_03 AC 51 ms
7,280 KB
testcase_04 AC 47 ms
6,012 KB
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 61 ms
7,016 KB
testcase_07 AC 62 ms
7,068 KB
testcase_08 AC 47 ms
5,952 KB
testcase_09 AC 73 ms
7,912 KB
testcase_10 AC 51 ms
6,136 KB
testcase_11 AC 71 ms
7,536 KB
testcase_12 AC 74 ms
7,960 KB
testcase_13 AC 74 ms
7,796 KB
testcase_14 AC 74 ms
7,776 KB
testcase_15 AC 73 ms
7,752 KB
testcase_16 AC 74 ms
7,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define all(a) begin(a), end(a)
#define sz(x) (int)((x).size())

#ifdef LOCAL
#include "debug.hpp"
#else
#define debug(...) 42
#endif

void solve() {
  int n; cin >> n;
  vector<ll> a(n + 1);
  for (int i = 1; i <= n; i++) {
    ll x; cin >> x; a[i] += x;
  }
  for (int i = 1; i <= n; i++) {
    ll x; cin >> x; a[i] += x;
  }
  vector<ll> s1(n + 1), s2(n + 1);
  for (int i = 1; i <= n; i++) {
    s1[i] = s1[i - 1] + a[i];
    s2[i] = s2[i - 1] + i * a[i];
  }
  for (int i = 1; i <= n * 2; i++) {
    int r = min(n, i - 1);
    int l = max(1, i - n) - 1;
    ll val = i * (s1[r] - s1[l]) - (s2[r] - s2[l]);
    cout << val << " \n"[i == n * 2];
  }
}

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);

  int T = 1;
  // cin >> T;
  while (T--) solve();

  return 0;
}
0