結果

問題 No.1219 Mancala Combo
ユーザー furafura
提出日時 2020-09-09 18:09:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 706 bytes
コンパイル時間 2,258 ms
コンパイル使用メモリ 199,892 KB
実行使用メモリ 4,664 KB
最終ジャッジ日時 2023-08-22 05:23:54
合計ジャッジ時間 5,624 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 20 ms
4,384 KB
testcase_18 AC 25 ms
4,376 KB
testcase_19 AC 18 ms
4,384 KB
testcase_20 AC 26 ms
4,384 KB
testcase_21 AC 15 ms
4,380 KB
testcase_22 AC 22 ms
4,376 KB
testcase_23 AC 24 ms
4,404 KB
testcase_24 AC 19 ms
4,376 KB
testcase_25 AC 17 ms
4,376 KB
testcase_26 AC 25 ms
4,380 KB
testcase_27 AC 27 ms
4,612 KB
testcase_28 AC 36 ms
4,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0