結果

問題 No.1618 Convolution?
ユーザー merom686merom686
提出日時 2021-07-22 21:44:59
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 755 bytes
コンパイル時間 2,604 ms
コンパイル使用メモリ 199,812 KB
実行使用メモリ 9,376 KB
最終ジャッジ日時 2023-09-24 16:18:52
合計ジャッジ時間 7,187 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 43 ms
7,848 KB
testcase_03 AC 51 ms
8,788 KB
testcase_04 AC 46 ms
6,920 KB
testcase_05 AC 5 ms
4,380 KB
testcase_06 AC 61 ms
8,436 KB
testcase_07 AC 63 ms
8,304 KB
testcase_08 AC 48 ms
6,964 KB
testcase_09 AC 72 ms
9,376 KB
testcase_10 AC 50 ms
7,212 KB
testcase_11 AC 68 ms
8,872 KB
testcase_12 AC 72 ms
9,368 KB
testcase_13 AC 71 ms
9,272 KB
testcase_14 AC 73 ms
9,268 KB
testcase_15 AC 72 ms
9,300 KB
testcase_16 AC 72 ms
9,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    vector<ll> a(n + 1), b(n + 1);
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        a[i + 1] = a[i] + t;
    }
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        b[i + 1] = b[i] + t;
        a[i + 1] += b[i + 1];
    }

    vector<ll> c(n * 2);
    for (int i = 0; i < n; i++) {
        c[i + 1] = c[i] + a[i + 1];
    }
    for (int i = 0; i < n - 1; i++) {
        c[n + i + 1] = c[n + i] - (a[i + 1] - a[i]) * n + a[n] - a[i + 1];
    }
    for (int i = 0; i < n * 2; i++) {
        cout << c[i] << " \n"[i == n * 2 - 1];
    }

    return 0;
}
0