結果
| 問題 |
No.1307 Rotate and Accumulate
|
| コンテスト | |
| ユーザー |
penguinman
|
| 提出日時 | 2020-12-04 02:02:25 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 759 bytes |
| コンパイル時間 | 2,182 ms |
| コンパイル使用メモリ | 200,804 KB |
| 最終ジャッジ日時 | 2025-01-16 15:33:06 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 TLE * 7 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
int N,Q,r,x,i,m,sum,cnt[100000];
vector<int> B;
short A[100000];
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
cin>>N>>Q;
for(i=0;i<N;i++){
cin>>A[i];
sum+=A[i];
}
while(Q--){
cin>>r;
cnt[r]++;
}
m=*min_element(cnt,cnt+N);
B.resize(N,m*sum);
for(i=0;i<N;i++){
cnt[i]-=m;
if(cnt[i]){
x=i;
for(r=0;r<N;r++,x++){
if(x==N) x=0;
B[r]+=A[x]*cnt[i];
}
}
}
cout<<B[0];
for(i=1;i<N;i++) cout<<" "<<B[i];
}
penguinman