結果

問題 No.1219 Mancala Combo
ユーザー WSKRWSKR
提出日時 2020-09-23 21:22:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 864 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 30,932 KB
最終ジャッジ日時 2023-09-10 12:36:36
合計ジャッジ時間 3,780 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,768 KB
testcase_01 AC 16 ms
7,744 KB
testcase_02 AC 15 ms
7,816 KB
testcase_03 AC 16 ms
7,904 KB
testcase_04 AC 16 ms
7,840 KB
testcase_05 AC 16 ms
7,772 KB
testcase_06 AC 16 ms
7,824 KB
testcase_07 AC 16 ms
7,788 KB
testcase_08 AC 16 ms
7,672 KB
testcase_09 AC 16 ms
7,896 KB
testcase_10 AC 16 ms
7,828 KB
testcase_11 AC 16 ms
7,772 KB
testcase_12 AC 16 ms
7,676 KB
testcase_13 AC 16 ms
7,808 KB
testcase_14 AC 16 ms
7,800 KB
testcase_15 AC 15 ms
7,800 KB
testcase_16 AC 16 ms
7,800 KB
testcase_17 AC 61 ms
20,004 KB
testcase_18 AC 83 ms
24,320 KB
testcase_19 AC 56 ms
18,804 KB
testcase_20 AC 86 ms
24,840 KB
testcase_21 AC 50 ms
17,260 KB
testcase_22 AC 75 ms
22,656 KB
testcase_23 AC 69 ms
23,240 KB
testcase_24 AC 67 ms
20,316 KB
testcase_25 AC 54 ms
18,268 KB
testcase_26 AC 82 ms
23,860 KB
testcase_27 AC 79 ms
24,968 KB
testcase_28 AC 111 ms
30,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#mancala combo
#segment tree

def main():
    N = int(input())
    a = list(map(int, input().split()))
    a.insert(0, 0)
    mindex = N + 1
    for i in range(1, N+1):
        if a[i] == i:
            mindex = i
    if mindex > N:
        print("No")
        return
    else:
        if any(a[j] > 0 for j in range(mindex+1, N+1)):
            print("No")
            return
        
        else:
            flag = True
            flowsum = 1
            for j in range(mindex-1, 0, -1):
                if  (flowsum+a[j]) % (j) != 0:
                    flag = False
                    break
                else:
                    flowsum = flowsum + (flowsum+a[j])//j
                    continue
            if flag:
                print("Yes")
            else:
                print("No")
            return


if __name__ == "__main__":
    main()

0