結果

問題 No.1307 Rotate and Accumulate
ユーザー risujirohrisujiroh
提出日時 2020-12-04 00:28:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,654 ms / 5,000 ms
コード長 602 bytes
コンパイル時間 3,046 ms
コンパイル使用メモリ 215,648 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-14 09:57:24
合計ジャッジ時間 12,334 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 414 ms
5,376 KB
testcase_09 AC 531 ms
5,376 KB
testcase_10 AC 352 ms
5,376 KB
testcase_11 AC 247 ms
5,376 KB
testcase_12 AC 373 ms
5,376 KB
testcase_13 AC 15 ms
5,376 KB
testcase_14 AC 94 ms
5,376 KB
testcase_15 AC 1,425 ms
5,376 KB
testcase_16 AC 1,413 ms
5,376 KB
testcase_17 AC 1,433 ms
5,376 KB
testcase_18 AC 28 ms
5,376 KB
testcase_19 AC 1,654 ms
5,376 KB
testcase_20 AC 35 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

constexpr int N = 1e5;

int a[N];
int b[2 * N];
int freq[N];

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; ++i) cin >> a[i];
  while (q--) {
    int r;
    cin >> r;
    if (r) r = n - r;
    ++freq[r];
  }

  for (int r = 0; r < n; ++r)
    if (freq[r]) {
      const int coeff = freq[r];
      for (int i = 0; i < n; ++i) b[r + i] += a[i] * coeff;
    }

  for (int i = 0; i < n; ++i) cout << b[i] + b[i + n] << " \n"[i == ~-n];
}
0