41602023-03-15 16:53:18kristofLeggyorsabb pénzkeresés (50)python3Accepted 50/50150ms36788 KiB
n, p = map(int, input().split())
arr = list(map(int, input().split()))

shortest=n+1

mostaniOsszeg = 0
bal = 0
jobb = 0

while jobb < n+1:
    if mostaniOsszeg < p:
        try:
            mostaniOsszeg += arr[jobb]
        except:
            break
        jobb+=1
    if mostaniOsszeg >= p:
        shortest = min(jobb-bal, shortest)
        mostaniOsszeg -= arr[bal]
        bal += 1






print(shortest)
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/017ms11096 KiB
2Accepted0/0145ms33752 KiB
3Accepted2/217ms11016 KiB
4Accepted2/217ms11536 KiB
5Accepted2/217ms11672 KiB
6Accepted2/229ms14056 KiB
7Accepted2/229ms14144 KiB
8Accepted2/229ms14200 KiB
9Accepted2/229ms14348 KiB
10Accepted2/228ms14080 KiB
11Accepted2/2145ms34980 KiB
12Accepted2/2143ms34884 KiB
13Accepted2/2146ms35208 KiB
14Accepted2/2144ms35228 KiB
15Accepted2/2143ms35420 KiB
16Accepted2/2143ms35736 KiB
17Accepted2/2142ms35872 KiB
18Accepted2/2144ms35764 KiB
19Accepted2/2142ms35944 KiB
20Accepted2/2141ms36104 KiB
21Accepted2/2146ms35852 KiB
22Accepted2/2150ms36144 KiB
23Accepted2/2142ms36212 KiB
24Accepted2/2148ms36232 KiB
25Accepted2/2143ms36568 KiB
26Accepted2/2150ms36408 KiB
27Accepted2/2143ms36788 KiB