結果

問題 No.1618 Convolution?
ユーザー CleyLCleyL
提出日時 2023-11-21 16:28:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 182 ms / 2,000 ms
コード長 623 bytes
コンパイル時間 766 ms
コンパイル使用メモリ 80,324 KB
実行使用メモリ 9,728 KB
最終ジャッジ日時 2023-11-21 16:28:46
合計ジャッジ時間 7,070 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 84 ms
8,248 KB
testcase_03 AC 102 ms
9,216 KB
testcase_04 AC 106 ms
7,296 KB
testcase_05 AC 10 ms
6,676 KB
testcase_06 AC 138 ms
8,552 KB
testcase_07 AC 139 ms
8,584 KB
testcase_08 AC 108 ms
7,424 KB
testcase_09 AC 167 ms
9,600 KB
testcase_10 AC 114 ms
7,552 KB
testcase_11 AC 157 ms
9,216 KB
testcase_12 AC 175 ms
9,728 KB
testcase_13 AC 175 ms
9,600 KB
testcase_14 AC 175 ms
9,600 KB
testcase_15 AC 176 ms
9,600 KB
testcase_16 AC 182 ms
9,600 KB
権限があれば一括ダウンロードができます

ソースコード

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