85312024-01-21 14:26:07NagyLeoLeggyorsabb pénzkeresés (50)python3Elfogadva 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()
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/018ms11016 KiB
2Elfogadva0/0103ms33124 KiB
3Elfogadva2/217ms11860 KiB
4Elfogadva2/217ms12164 KiB
5Elfogadva2/217ms12120 KiB
6Elfogadva2/226ms14412 KiB
7Elfogadva2/226ms14652 KiB
8Elfogadva2/225ms14792 KiB
9Elfogadva2/225ms15192 KiB
10Elfogadva2/225ms15084 KiB
11Elfogadva2/297ms34560 KiB
12Elfogadva2/2101ms34872 KiB
13Elfogadva2/2101ms34892 KiB
14Elfogadva2/2101ms34920 KiB
15Elfogadva2/2101ms34992 KiB
16Elfogadva2/2105ms35080 KiB
17Elfogadva2/2101ms34724 KiB
18Elfogadva2/2101ms34836 KiB
19Elfogadva2/2101ms35092 KiB
20Elfogadva2/2101ms34968 KiB
21Elfogadva2/2101ms35396 KiB
22Elfogadva2/2104ms35300 KiB
23Elfogadva2/2101ms35680 KiB
24Elfogadva2/2101ms35760 KiB
25Elfogadva2/2103ms35276 KiB
26Elfogadva2/2104ms35360 KiB
27Elfogadva2/2101ms35028 KiB