結果

問題 No.1618 Convolution?
ユーザー 👑 CleyL
提出日時 2023-11-21 16:28:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 623 bytes
コンパイル時間 841 ms
コンパイル使用メモリ 78,244 KB
最終ジャッジ日時 2025-02-17 22:45:26
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main(){
  int n;cin>>n;
  vector<long long> A(n),B(2*n);
  for(int i = 0; n > i; i++){
    long long x;cin>>x;A[i]+=x;
  }
  for(int i = 0; n > i; i++){
    long long x;cin>>x;A[i]+=x;
  }
  queue<long long> C;
  long long sm = 0;
  long long offset = 0;
  for(int i = 0; 2*n-1 > i; i++){
    if(i < n){
      sm += A[i];
      C.push(A[i]);
    }
    if(i >= n){
      offset = -n*C.front();
      sm -= C.front();C.pop();
    }
    B[i+1] = B[i]+sm+offset;
  }
  for(int i = 0; 2*n > i; i++){
    cout << B[i] << " ";
  }
  cout << endl;
}
0