結果
| 問題 |
No.1307 Rotate and Accumulate
|
| コンテスト | |
| ユーザー |
りあん
|
| 提出日時 | 2020-12-04 01:32:30 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,163 bytes |
| コンパイル時間 | 9,704 ms |
| コンパイル使用メモリ | 274,256 KB |
| 最終ジャッジ日時 | 2025-01-16 15:23:51 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 TLE * 3 |
ソースコード
#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;
vector<int> a(n);
int sum = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i];
sum += a[i];
}
vector<int> cnt(n);
for (int i = 0; i < q; ++i) {
int x;
cin >> x;
++cnt[x];
}
vector<int> c(q + 1);
for (int i = 0; i < n; ++i) {
++c[cnt[i]];
}
int freq = -1, ma = -1;
for (int i = 0; i <= q; ++i) {
if (ma < c[i]) {
ma = c[i];
freq = i;
}
}
vector<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;
}
りあん