Submission #34226132


Source Code Expand

#!/usr/bin/env python3


def main():
    def meguru(start, target):
        if start > N:
            return None
        left: int = start - 1
        right: int = N
        while abs(left - right) > 1:
            mid = (left + right) // 2
            if cs[mid] - cs[start] >= target:  # isOk()
                right = mid
            else:
                left = mid
        if cs[right] - cs[start] == target:
            if start < right <= N:
                return right
        return None

    def solve():
        for i in range(N - 2):
            x = meguru(i, P)
            if x is not None:
                y = meguru(x, Q)
                if y is not None:
                    z = meguru(y, R)
                    if z is not None:
                        print("Yes")
                        return
        print("No")

    N, P, Q, R = map(int, input().split())
    A = list(map(int, input().split()))
    cs = [0]  # si=[0,i)の和 [a,b)の和=sb−sa 遅かったらnumpy
    for i in A:
        cs.append(cs[-1] + i)
    solve()


if __name__ == "__main__":
    main()

Submission Info

Submission Time
Task D - Iroha and Haiku (New ABC Edition)
User rainline
Language PyPy3 (7.3.0)
Score 400
Code Size 1091 Byte
Status AC
Exec Time 163 ms
Memory 107652 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 25
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 163 ms 107332 KiB
random_02.txt AC 109 ms 91140 KiB
random_03.txt AC 127 ms 107008 KiB
random_04.txt AC 115 ms 101732 KiB
random_05.txt AC 146 ms 107284 KiB
random_06.txt AC 129 ms 107652 KiB
random_07.txt AC 127 ms 107204 KiB
random_08.txt AC 111 ms 104224 KiB
random_09.txt AC 111 ms 107300 KiB
random_10.txt AC 90 ms 97468 KiB
random_11.txt AC 102 ms 107100 KiB
random_12.txt AC 101 ms 105576 KiB
random_13.txt AC 106 ms 107144 KiB
random_14.txt AC 108 ms 104756 KiB
random_15.txt AC 107 ms 106952 KiB
random_16.txt AC 77 ms 86576 KiB
random_17.txt AC 103 ms 107308 KiB
random_18.txt AC 49 ms 61824 KiB
random_19.txt AC 95 ms 97228 KiB
random_20.txt AC 146 ms 97252 KiB
random_21.txt AC 119 ms 97280 KiB
random_22.txt AC 48 ms 61824 KiB
sample_01.txt AC 49 ms 61780 KiB
sample_02.txt AC 53 ms 62016 KiB
sample_03.txt AC 50 ms 61980 KiB