117322024-11-08 13:07:11balintLeggyorsabb pénzkeresés (50)python3Time limit exceeded 8/50300ms14712 KiB
def main():
    N, P = map(int, input().split())
    nums = list(map(int, input().split()))
    prefix_sum = [0] * (N + 1)
    for i in range(1, N + 1):
        prefix_sum[i] = prefix_sum[i - 1] + nums[i - 1]

    for n in range(1, N + 1):
        for i in range(N - n + 1):
            subarray_sum = prefix_sum[i + n] - prefix_sum[i]
            if subarray_sum >= P:
                print(n)
                return


main()
SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/016ms3128 KiB
2Time limit exceeded0/0287ms14616 KiB
3Accepted2/216ms3140 KiB
4Accepted2/216ms3040 KiB
5Accepted2/217ms3024 KiB
6Time limit exceeded0/2264ms4152 KiB
7Time limit exceeded0/2300ms4036 KiB
8Time limit exceeded0/2284ms4152 KiB
9Time limit exceeded0/2245ms4152 KiB
10Time limit exceeded0/2300ms4152 KiB
11Accepted2/271ms14620 KiB
12Time limit exceeded0/2300ms14532 KiB
13Time limit exceeded0/2282ms14592 KiB
14Time limit exceeded0/2286ms14712 KiB
15Time limit exceeded0/2282ms14616 KiB
16Time limit exceeded0/2282ms14620 KiB
17Time limit exceeded0/2280ms14620 KiB
18Time limit exceeded0/2287ms14632 KiB
19Time limit exceeded0/2280ms14616 KiB
20Time limit exceeded0/2286ms14576 KiB
21Time limit exceeded0/2280ms14620 KiB
22Time limit exceeded0/2282ms14632 KiB
23Time limit exceeded0/2282ms14620 KiB
24Time limit exceeded0/2282ms14616 KiB
25Time limit exceeded0/2282ms14620 KiB
26Time limit exceeded0/2282ms14620 KiB
27Time limit exceeded0/2282ms14620 KiB