結果

問題 No.1307 Rotate and Accumulate
ユーザー りあんりあん
提出日時 2021-06-14 15:36:09
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 989 ms / 5,000 ms
コード長 719 bytes
コンパイル時間 4,799 ms
コンパイル使用メモリ 215,768 KB
実行使用メモリ 5,132 KB
最終ジャッジ日時 2023-08-26 00:38:31
合計ジャッジ時間 14,593 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 446 ms
4,596 KB
testcase_09 AC 549 ms
4,452 KB
testcase_10 AC 219 ms
4,376 KB
testcase_11 AC 419 ms
4,444 KB
testcase_12 AC 235 ms
4,380 KB
testcase_13 AC 12 ms
4,380 KB
testcase_14 AC 65 ms
4,380 KB
testcase_15 AC 973 ms
4,888 KB
testcase_16 AC 989 ms
4,944 KB
testcase_17 AC 981 ms
4,884 KB
testcase_18 AC 969 ms
5,024 KB
testcase_19 AC 987 ms
5,132 KB
testcase_20 AC 977 ms
4,892 KB
testcase_21 AC 1 ms
4,380 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[j] += a[i + j] * cnt[i];
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << b[i] << (i < n - 1 ? ' ' : '\n');
    }

    return 0;
}
0