結果

問題 No.754 畳み込みの和
ユーザー NoiriNoiri
提出日時 2019-09-18 16:18:04
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 5,000 ms
コード長 645 bytes
コンパイル時間 1,595 ms
コンパイル使用メモリ 167,172 KB
実行使用メモリ 4,700 KB
最終ジャッジ日時 2023-09-22 18:08:43
合計ジャッジ時間 2,589 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
4,700 KB
testcase_01 AC 78 ms
4,668 KB
testcase_02 AC 77 ms
4,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

const ll Mod = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    n++;
    vector<ll> a(n+1), b(n+1);
    rep(i, n) cin >> a[i];
    rep(i, n){
        ll tmp;
        cin >> tmp;
        b[i+1] += tmp + b[i];
        b[i+1] %= Mod;
    }
    reverse(all(b));

    ll ans = 0;
    rep(i, n){
        ans += (a[i] * b[i]) % Mod;
        ans %= Mod;
    }

    cout << ans << endl;
}
0