結果

問題 No.1618 Convolution?
ユーザー hayatenhayaten
提出日時 2021-08-10 14:41:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 182 ms / 2,000 ms
コード長 1,673 bytes
コンパイル時間 8,288 ms
コンパイル使用メモリ 279,544 KB
実行使用メモリ 15,968 KB
最終ジャッジ日時 2023-10-23 22:28:38
合計ジャッジ時間 12,500 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 89 ms
13,064 KB
testcase_03 AC 106 ms
14,980 KB
testcase_04 AC 109 ms
11,284 KB
testcase_05 AC 11 ms
4,348 KB
testcase_06 AC 142 ms
13,592 KB
testcase_07 AC 142 ms
13,592 KB
testcase_08 AC 113 ms
11,284 KB
testcase_09 AC 179 ms
15,704 KB
testcase_10 AC 117 ms
11,812 KB
testcase_11 AC 161 ms
15,176 KB
testcase_12 AC 180 ms
15,968 KB
testcase_13 AC 180 ms
15,968 KB
testcase_14 AC 182 ms
15,968 KB
testcase_15 AC 180 ms
15,968 KB
testcase_16 AC 179 ms
15,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma region Macros
// #pragma GCC target("avx2")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define popcount(bit) __builtin_popcount(bit)
#define popcountll(bit) __builtin_popcountll(bit)
#define pb push_back
#define eb emplace_back
using namespace std;
using namespace atcoder;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Graph = vector<vector<int>>;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int fx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int fy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
template <typename T>
const auto INF = numeric_limits<T>::max();

int main() {
  int n;
  cin >> n;
  vector<ll> A(n), B(n), sum_A(n + 1, 0), sum_B(n + 1, 0);
  vector<ll> CA(2 * n), CB(2 * n);
  rep(i, n) cin >> A[i];
  rep(i, n) cin >> B[i];
  rep(i, n){
    sum_A[i + 1] = sum_A[i] + A[i];
    sum_B[i + 1] = sum_B[i] + B[i];
  }
  CA[1] = sum_A[1];
  CB[1] = sum_B[1];
  for (int i = 2; i < 2 *n; i++){
    if(i <= n){
      CA[i] = CA[i - 1] + sum_A[i];
      CB[i] = CB[i - 1] + sum_B[i];
    }else{
      CA[i] = CA[i - 1] + sum_A[n] - sum_A[i - n] - n * A[i - n - 1];
      CB[i] = CB[i - 1] + sum_B[n] - sum_B[i - n] - n * B[i - n - 1];
    }
  }
  rep(i, 2 * n){
    cout << CA[i] + CB[i] << (i == 2 * n -1 ? "\n" : " ");
  }
}
0