結果

問題 No.1307 Rotate and Accumulate
ユーザー risujirohrisujiroh
提出日時 2020-12-04 00:28:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,632 ms / 5,000 ms
コード長 602 bytes
コンパイル時間 3,231 ms
コンパイル使用メモリ 211,960 KB
実行使用メモリ 4,988 KB
最終ジャッジ日時 2023-10-12 11:05:00
合計ジャッジ時間 13,683 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 467 ms
4,452 KB
testcase_09 AC 595 ms
4,500 KB
testcase_10 AC 398 ms
4,352 KB
testcase_11 AC 274 ms
4,372 KB
testcase_12 AC 413 ms
4,372 KB
testcase_13 AC 14 ms
4,352 KB
testcase_14 AC 103 ms
4,352 KB
testcase_15 AC 1,473 ms
4,944 KB
testcase_16 AC 1,401 ms
4,940 KB
testcase_17 AC 1,417 ms
4,988 KB
testcase_18 AC 27 ms
4,348 KB
testcase_19 AC 1,632 ms
4,984 KB
testcase_20 AC 33 ms
4,352 KB
testcase_21 AC 2 ms
4,348 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