41112023-03-14 22:10:09kristofLeggyorsabb pénzkeresés (50)python3Wrong answer 4/50108ms36876 KiB
n, p = map(int, input().split())
arr = list(map(int, input().split()))

eddigi = 0
bal = 0
jobb = 0
eddigi = arr[0]
shortest=n+1

for i in range(n):
    if eddigi < p:
        jobb += 1
        eddigi += arr[jobb]
    
    if eddigi > p:
        eddigi -= arr[bal]
        bal += 1
    if eddigi == p:
        shortest = min(jobb-bal+1, shortest)

print(shortest)
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/017ms11044 KiB
2Wrong answer0/0103ms33772 KiB
3Wrong answer0/217ms11720 KiB
4Accepted2/217ms11708 KiB
5Wrong answer0/217ms11920 KiB
6Wrong answer0/225ms14328 KiB
7Wrong answer0/225ms14488 KiB
8Wrong answer0/226ms14432 KiB
9Wrong answer0/225ms14724 KiB
10Wrong answer0/226ms14952 KiB
11Wrong answer0/2101ms35580 KiB
12Wrong answer0/2104ms35676 KiB
13Wrong answer0/2100ms35836 KiB
14Wrong answer0/2108ms36064 KiB
15Wrong answer0/2100ms36132 KiB
16Wrong answer0/298ms36132 KiB
17Wrong answer0/2101ms36148 KiB
18Wrong answer0/2103ms36424 KiB
19Wrong answer0/2100ms36520 KiB
20Wrong answer0/2100ms36784 KiB
21Wrong answer0/2100ms36792 KiB
22Wrong answer0/2103ms36516 KiB
23Accepted2/2103ms36708 KiB
24Wrong answer0/2103ms36716 KiB
25Wrong answer0/2101ms36876 KiB
26Wrong answer0/2104ms36720 KiB
27Wrong answer0/2104ms36824 KiB