117662024-11-09 17:02:40balintSokszorozott maximumokpython3Time limit exceeded 11/1002.101s26500 KiB
from math import prod
from heapq import nlargest
def main():
    MOD = 10**9 + 7
    N, Q = map(int, input().split())
    nums = list(map(int, input().split()))
    for _ in range(Q):
        L, R, k = map(int, input().split())
        sub = nums[L : R + 1]
        # mul = reduce(memo_mul, sorted(sub, reverse=True)[:k], 1)
        mul = prod(nlargest(k, sub))
        print(mul % MOD)


main()
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted16ms3128 KiB
subtask211/11
2Accepted32ms3304 KiB
3Accepted41ms3132 KiB
4Accepted326ms3528 KiB
5Accepted828ms3640 KiB
6Accepted18ms3080 KiB
7Accepted212ms3272 KiB
subtask30/13
8Accepted29ms3124 KiB
9Accepted32ms3176 KiB
10Accepted239ms3312 KiB
11Time limit exceeded2.078s14072 KiB
12Time limit exceeded2.082s26312 KiB
13Time limit exceeded2.101s26188 KiB
subtask40/19
14Time limit exceeded2.082s21576 KiB
15Time limit exceeded2.082s23996 KiB
16Time limit exceeded2.082s26500 KiB
17Time limit exceeded2.079s26252 KiB
18Time limit exceeded2.076s26196 KiB
subtask50/25
19Time limit exceeded2.073s9384 KiB
20Time limit exceeded2.073s8396 KiB
21Time limit exceeded2.075s8204 KiB
22Time limit exceeded2.073s9224 KiB
23Time limit exceeded2.089s6888 KiB
subtask60/32
24Time limit exceeded2.094s26404 KiB
25Time limit exceeded2.092s26196 KiB
26Time limit exceeded2.092s21572 KiB
27Time limit exceeded2.094s23900 KiB
28Time limit exceeded2.082s26276 KiB
29Time limit exceeded2.082s26188 KiB
30Time limit exceeded2.082s24040 KiB