結果

問題 No.1219 Mancala Combo
ユーザー titiatitia
提出日時 2020-09-04 21:42:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 804 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 105,472 KB
最終ジャッジ日時 2024-05-04 21:58:39
合計ジャッジ時間 3,083 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
51,712 KB
testcase_01 AC 41 ms
51,840 KB
testcase_02 AC 42 ms
51,968 KB
testcase_03 AC 41 ms
51,712 KB
testcase_04 WA -
testcase_05 AC 42 ms
52,224 KB
testcase_06 WA -
testcase_07 AC 42 ms
51,712 KB
testcase_08 WA -
testcase_09 AC 41 ms
51,840 KB
testcase_10 WA -
testcase_11 AC 41 ms
52,480 KB
testcase_12 WA -
testcase_13 AC 42 ms
52,096 KB
testcase_14 AC 41 ms
51,968 KB
testcase_15 AC 41 ms
52,096 KB
testcase_16 WA -
testcase_17 AC 85 ms
93,824 KB
testcase_18 WA -
testcase_19 AC 80 ms
88,448 KB
testcase_20 WA -
testcase_21 AC 72 ms
83,584 KB
testcase_22 WA -
testcase_23 AC 95 ms
101,376 KB
testcase_24 WA -
testcase_25 AC 82 ms
88,448 KB
testcase_26 WA -
testcase_27 AC 95 ms
104,064 KB
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

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)
    if V%i!=0:
        print("No")
        break
    else:
        updates(0,i,V)
else:
    print("Yes")
    
0