結果

問題 No.1618 Convolution?
ユーザー yumaruyumaru
提出日時 2021-07-22 22:25:51
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 1,602 bytes
コンパイル時間 2,041 ms
コンパイル使用メモリ 200,548 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2023-09-24 17:35:54
合計ジャッジ時間 8,233 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 78 ms
10,300 KB
testcase_03 AC 95 ms
11,756 KB
testcase_04 AC 101 ms
8,804 KB
testcase_05 AC 9 ms
4,376 KB
testcase_06 AC 133 ms
10,540 KB
testcase_07 AC 130 ms
10,968 KB
testcase_08 AC 101 ms
9,072 KB
testcase_09 AC 154 ms
12,352 KB
testcase_10 AC 106 ms
9,480 KB
testcase_11 AC 147 ms
11,648 KB
testcase_12 AC 164 ms
12,544 KB
testcase_13 AC 163 ms
12,484 KB
testcase_14 AC 164 ms
12,364 KB
testcase_15 AC 165 ms
12,440 KB
testcase_16 AC 165 ms
12,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for (int i = a; i < b; i++)
#define rrep(i,a,b) for (int i = a - 1; i >= b; i--)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define pvec(a) for (int i = 0; i < a.size(); i++) cout << a[i] << " "; cout << '\n'
#define dbwt(a) cout << fixed << setprecision(15) << a << '\n'
using namespace std;
using ll = long long;
void wt() {cout << endl;}
template<class T, class U>bool chmin(T& a, U b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U>bool chmax(T& a, U b) {if (a < b) {a = b; return 1;} return 0;}
template<class T, class U>long long llceil(T a, U b) {return (long long)(a + b - 1) / b;}
template<class H, class...T>void wt(H&& h, T&&... t){cout<<h<<" "; wt(forward<T>(t)...);}

//-------------------------------------------------------------------------------------//

int main() {
    int N;
    cin >> N;
    vector<ll> A(2*N+1, 0), B(2*N+1, 0);
    rep (i, 1, N+1) cin >> A[i];
    rep (i, 1, N+1) cin >> B[i];

    vector<ll> C(2*N+1, 0);

    ll nsumA = A[1], nsumB = B[1];
    rep (k, 2, 2*N+1) {

        if (k >= N + 1) {
            

            C[k] = C[k-1] + nsumA + nsumB - (ll)(N+1)*A[k-N-1] - (ll)(N+1)*B[k-N-1];

            nsumA -= A[k-N-1];
            nsumB -= B[k-N-1];
        }
        else {
            C[k] = C[k-1] + nsumA + nsumB;
        }

        
        nsumA += A[k];
        nsumB += B[k];
        
        
    }
    
    rep (i, 1, 2*N+1) cout << C[i] << " "; cout << endl;
    return 0;
}
0