結果

問題 No.1219 Mancala Combo
ユーザー titiatitia
提出日時 2020-09-04 21:44:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 823 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 81,804 KB
実行使用メモリ 110,080 KB
最終ジャッジ日時 2024-05-04 22:00:23
合計ジャッジ時間 2,798 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
51,712 KB
testcase_01 AC 36 ms
52,352 KB
testcase_02 AC 33 ms
52,224 KB
testcase_03 AC 34 ms
51,968 KB
testcase_04 AC 55 ms
58,496 KB
testcase_05 AC 34 ms
52,096 KB
testcase_06 AC 34 ms
52,224 KB
testcase_07 AC 34 ms
51,712 KB
testcase_08 AC 38 ms
58,752 KB
testcase_09 AC 33 ms
52,096 KB
testcase_10 AC 33 ms
52,352 KB
testcase_11 AC 33 ms
52,096 KB
testcase_12 AC 34 ms
51,712 KB
testcase_13 AC 33 ms
52,224 KB
testcase_14 AC 32 ms
51,968 KB
testcase_15 AC 33 ms
51,968 KB
testcase_16 AC 32 ms
51,968 KB
testcase_17 AC 89 ms
93,440 KB
testcase_18 AC 117 ms
100,608 KB
testcase_19 AC 68 ms
88,320 KB
testcase_20 AC 125 ms
102,912 KB
testcase_21 AC 58 ms
83,712 KB
testcase_22 AC 114 ms
96,128 KB
testcase_23 AC 75 ms
101,760 KB
testcase_24 AC 104 ms
93,480 KB
testcase_25 AC 65 ms
88,192 KB
testcase_26 AC 117 ms
100,224 KB
testcase_27 AC 77 ms
103,936 KB
testcase_28 AC 149 ms
110,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int,input().split()))

seg_el=1<<((N+1).bit_length()) # Segment treeの台の要素数
SEG=[0]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化

for i in range(N):
    SEG[i+seg_el+1]=A[i]

def getvalue(n,seg_el): # 一点の値を取得
    i=n+seg_el

    ANS=SEG[i]
    i>>=1 # 子ノードへ
    
    while i!=0:
        ANS+=SEG[i]
        i>>=1

    return ANS

def updates(l,r,x):
    L=l+seg_el
    R=r+seg_el

    while L<R:
        if L & 1:
            SEG[L]+=x
            L+=1

        if R & 1:
            R-=1
            SEG[R]+=x
        L>>=1
        R>>=1

for i in range(N,0,-1):
    V=getvalue(i,seg_el)
    #print(V,i)
    if V%i!=0:
        print("No")
        break
    else:
        updates(0,i,V//i)
else:
    print("Yes")
    
0