結果

問題 No.1307 Rotate and Accumulate
ユーザー りあんりあん
提出日時 2020-12-04 01:31:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,128 bytes
コンパイル時間 1,959 ms
コンパイル使用メモリ 200,240 KB
実行使用メモリ 9,608 KB
最終ジャッジ日時 2023-10-12 12:45:23
合計ジャッジ時間 16,088 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 3,839 ms
4,348 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 2,253 ms
4,352 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    vector<unsigned int> a(n);
    unsigned int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    vector<unsigned int> cnt(n);
    for (int i = 0; i < q; ++i) {
        int x;
        cin >> x;
        ++cnt[x];
    }
    vector<unsigned int> c(q + 1);
    for (int i = 0; i <= q; ++i) {
        ++c[cnt[i]];
    }
    unsigned int freq = 0, ma = c[0];
    for (int i = 0; i <= q; ++i) {
        if (ma < c[i]) {
            ma = c[i];
            freq = i;
        }
    }
    vector<unsigned int> b(n);
    for (int i = 0; i < n; ++i) {
        b[i] = freq * sum;
        cnt[i] -= freq;
    }
    for (int i = 0; i < n; ++i) {
        if (cnt[i] == 0) continue;
        for (int j = 0; j < n; ++j) {
            b[j] += cnt[i] * a[i + j < n ? i + j : i + j - n];
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << b[i] << (i < n - 1 ? ' ' : '\n');
    }
    return 0;
}
0