結果

問題 No.1219 Mancala Combo
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-15 14:19:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 799 bytes
コンパイル時間 1,543 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 108,768 KB
最終ジャッジ日時 2023-08-27 05:19:12
合計ジャッジ時間 7,136 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
72,160 KB
testcase_01 AC 93 ms
72,152 KB
testcase_02 AC 93 ms
71,948 KB
testcase_03 AC 90 ms
71,880 KB
testcase_04 AC 90 ms
72,016 KB
testcase_05 AC 93 ms
72,416 KB
testcase_06 AC 88 ms
72,116 KB
testcase_07 AC 92 ms
72,468 KB
testcase_08 AC 89 ms
72,008 KB
testcase_09 AC 91 ms
72,144 KB
testcase_10 AC 94 ms
71,916 KB
testcase_11 AC 91 ms
72,064 KB
testcase_12 AC 93 ms
72,460 KB
testcase_13 AC 92 ms
72,452 KB
testcase_14 AC 92 ms
72,056 KB
testcase_15 AC 91 ms
72,060 KB
testcase_16 AC 94 ms
72,328 KB
testcase_17 AC 124 ms
98,200 KB
testcase_18 AC 128 ms
98,776 KB
testcase_19 AC 121 ms
95,260 KB
testcase_20 AC 131 ms
101,044 KB
testcase_21 AC 115 ms
92,740 KB
testcase_22 AC 126 ms
96,044 KB
testcase_23 AC 127 ms
103,644 KB
testcase_24 AC 121 ms
92,920 KB
testcase_25 AC 118 ms
94,880 KB
testcase_26 AC 126 ms
98,384 KB
testcase_27 AC 133 ms
108,400 KB
testcase_28 AC 142 ms
108,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main0(n,a):
	while True:
		flg=False
		for i in range(n):
			if a[i]==i+1:
				a[i]=0
				flg=True
				break
			else:
				a[i]+=1
		if not flg:
			if a==[1]*n:return True
			return False
def main1(n,a):
	ary=[0]*n
	cnt=0
	for i in range(n-1,-1,-1):
		x=a[i]
		if (x+cnt)%(i+1)!=0 or x>i+1:
			return False
		cnt+=(x+cnt)//(i+1)
	return True

if __name__=='__main__':
	n=int(input())
	a=list(map(int,input().split()))
	#ret0=main0(n,a[:])
	#print("Yes" if ret0 else "No")
	ret1=main1(n,a)
	print("Yes" if ret1 else "No")
from random import randint
if __name__=='__main__1':
	for _ in range(500):
		n=randint(2,20)
		a=[randint(0,n) for _ in range(n)]
		if all(x==0 for x in a):continue
		ret0=main0(n,a[:])
		ret1=main1(n,a)
		if ret0!=ret1:
			print(n)
			print(*a)
			print(ret0,ret1)
			break
0