85312024-01-21 14:26:07NagyLeoLeggyorsabb pénzkeresés (50)python3Accepted 50/50105ms35760 KiB
'''from sys import stdin, stdout


def main():
    NP = list(stdin.readline().split())
    N = int(NP[0])
    P = int(NP[1])
    smallest = N+1

    days = list(map(int, stdin.readline().split()))
    for i in range(0, len(days)):
        current = 0
        countr = 0
        for f in range(i, len(days)):
            countr += 1
            current += days[f]
            if current >= P:
                if countr < smallest:
                    smallest = countr
                break

    stdout.write(str(smallest))


main()
'''

from sys import stdin, stdout

def main():
    N, P = map(int, stdin.readline().split())
    days = list(map(int, stdin.readline().split()))

    smallest = N + 1
    current_sum = 0
    left_pointer = 0

    for right_pointer in range(N):
        current_sum += days[right_pointer]

        while current_sum >= P:
            smallest = min(smallest, right_pointer - left_pointer + 1)
            current_sum -= days[left_pointer]
            left_pointer += 1

    stdout.write(str(smallest))

main()
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/018ms11016 KiB
2Accepted0/0103ms33124 KiB
3Accepted2/217ms11860 KiB
4Accepted2/217ms12164 KiB
5Accepted2/217ms12120 KiB
6Accepted2/226ms14412 KiB
7Accepted2/226ms14652 KiB
8Accepted2/225ms14792 KiB
9Accepted2/225ms15192 KiB
10Accepted2/225ms15084 KiB
11Accepted2/297ms34560 KiB
12Accepted2/2101ms34872 KiB
13Accepted2/2101ms34892 KiB
14Accepted2/2101ms34920 KiB
15Accepted2/2101ms34992 KiB
16Accepted2/2105ms35080 KiB
17Accepted2/2101ms34724 KiB
18Accepted2/2101ms34836 KiB
19Accepted2/2101ms35092 KiB
20Accepted2/2101ms34968 KiB
21Accepted2/2101ms35396 KiB
22Accepted2/2104ms35300 KiB
23Accepted2/2101ms35680 KiB
24Accepted2/2101ms35760 KiB
25Accepted2/2103ms35276 KiB
26Accepted2/2104ms35360 KiB
27Accepted2/2101ms35028 KiB