結果

問題 No.1307 Rotate and Accumulate
ユーザー りあん
提出日時 2020-12-04 01:48:29
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2,130 ms / 5,000 ms
コード長 719 bytes
コンパイル時間 3,250 ms
コンパイル使用メモリ 217,312 KB
最終ジャッジ日時 2025-01-16 15:27:12
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const long long LM = 1LL << 60;

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