結果
| 問題 |
No.1219 Mancala Combo
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-09 18:09:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 2,000 ms |
| コード長 | 706 bytes |
| コンパイル時間 | 2,266 ms |
| コンパイル使用メモリ | 194,612 KB |
| 最終ジャッジ日時 | 2025-01-14 08:56:40 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | int n; scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:33:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
33 | int a; scanf("%d",&a);
| ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
template<class G>
class Fenwick_tree_dual{
vector<G> a;
public:
Fenwick_tree_dual(int n):a(n){}
void add(int l,int r,const G& val){
if(l==0){
for(;r>0;r-=r&-r) a[r-1]+=val;
return;
}
add(0,r,val);
add(0,l,-val);
}
G sum(int i)const{
G res{};
for(i++;i<=a.size();i+=i&-i) res+=a[i-1];
return res;
}
};
int main(){
int n; scanf("%d",&n);
Fenwick_tree_dual<lint> F(n+1);
rep(i,n){
int a; scanf("%d",&a);
F.add(i+1,i+2,a);
}
for(int i=n;i>0;i--){
lint x=F.sum(i);
if(x%i!=0){
puts("No");
return 0;
}
F.add(0,i,x/i);
}
puts("Yes");
return 0;
}