結果

問題 No.1618 Convolution?
ユーザー umezoumezo
提出日時 2021-07-22 22:06:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 791 bytes
コンパイル時間 2,376 ms
コンパイル使用メモリ 201,432 KB
実行使用メモリ 15,580 KB
最終ジャッジ日時 2023-09-24 17:07:44
合計ジャッジ時間 7,639 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 54 ms
12,696 KB
testcase_03 AC 63 ms
14,604 KB
testcase_04 AC 56 ms
10,904 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 73 ms
13,180 KB
testcase_07 AC 72 ms
13,256 KB
testcase_08 AC 57 ms
10,892 KB
testcase_09 AC 87 ms
15,400 KB
testcase_10 AC 60 ms
11,516 KB
testcase_11 AC 81 ms
14,476 KB
testcase_12 AC 86 ms
15,504 KB
testcase_13 AC 87 ms
15,580 KB
testcase_14 AC 86 ms
15,524 KB
testcase_15 AC 86 ms
15,564 KB
testcase_16 AC 87 ms
15,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  vector<ll> A(n+1),B(n+1);
  rep(i,n) cin>>A[i+1];
  rep(i,n) cin>>B[i+1];
  
  vector<ll> SA(n+2),SB(n+2);
  for(int i=1;i<=n;i++) SA[i]=SA[i-1]+A[i];
  for(int i=1;i<=n;i++) SB[i]=SB[i-1]+B[i];
  
  vector<ll> AA(2*n+2),BB(2*n+2);
  for(int i=2;i<=n+1;i++){
    AA[i]=AA[i-1]+SA[i-1];
    BB[i]=BB[i-1]+SB[i-1];
  }
  for(int i=n+2;i<=2*n;i++){
    AA[i]=AA[i-1]-n*A[i-n-1]+SA[n]-SA[i-n-1];
    BB[i]=BB[i-1]-n*B[i-n-1]+SB[n]-SB[i-n-1];
  }
  for(int i=1;i<=2*n;i++){
    if(i!=1) cout<<" ";
    cout<<AA[i]+BB[i];
  }
  cout<<endl;
  
  return 0;
}
0