結果
| 問題 | 
                            No.1307 Rotate and Accumulate
                             | 
                    
| コンテスト | |
| ユーザー | 
                             りあん
                         | 
                    
| 提出日時 | 2021-06-14 15:36:09 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1,377 ms / 5,000 ms | 
| コード長 | 719 bytes | 
| コンパイル時間 | 4,356 ms | 
| コンパイル使用メモリ | 218,576 KB | 
| 最終ジャッジ日時 | 2025-01-22 08:12:56 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
ソースコード
#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;
}
            
            
            
        
            
りあん