結果

問題 No.1307 Rotate and Accumulate
ユーザー りあんりあん
提出日時 2021-06-14 11:32:46
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 833 ms / 5,000 ms
コード長 719 bytes
コンパイル時間 3,507 ms
コンパイル使用メモリ 215,048 KB
実行使用メモリ 5,184 KB
最終ジャッジ日時 2023-08-25 20:29:19
合計ジャッジ時間 14,094 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 380 ms
4,756 KB
testcase_09 AC 427 ms
4,540 KB
testcase_10 AC 191 ms
4,376 KB
testcase_11 AC 329 ms
4,384 KB
testcase_12 AC 204 ms
4,376 KB
testcase_13 AC 12 ms
4,380 KB
testcase_14 AC 54 ms
4,380 KB
testcase_15 AC 822 ms
5,056 KB
testcase_16 AC 817 ms
5,004 KB
testcase_17 AC 833 ms
4,940 KB
testcase_18 AC 817 ms
4,928 KB
testcase_19 AC 817 ms
4,932 KB
testcase_20 AC 820 ms
5,184 KB
testcase_21 AC 1 ms
4,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
using namespace std;

const int B = 1000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, q;
    cin >> n >> q;
    int a[n * 2];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[n + i] = a[i];
    }
    int cnt[n] = {};
    for (int i = 0; i < q; ++i) {
        int r;
        cin >> r;
        ++cnt[r];
    }
    int b[n] = {};
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            b[i] += a[i + j] * cnt[j];
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << b[i] << (i < n - 1 ? ' ' : '\n');
    }

    return 0;
}
0