86392024-01-24 16:12:01NagyLeoMI bróker (50 pont)python3Time limit exceeded 8/501.083s14540 KiB
from sys import stdin, stdout


def main():
    NQ = list(map(int, stdin.readline().split()))
    N = NQ[0]
    Q = NQ[1]
    Prices = list(map(int, stdin.readline().split()))
    balance = []

    for i in range(0, Q):
        isHolding = False
        curBalance = 0
        current_ord = list(map(int, stdin.readline().split()))
        for f in Prices:
            if isHolding == False and current_ord[0] >= f:
                curBalance -= f
                isHolding = True
            if isHolding == True and current_ord[1] <= f:
                curBalance += f
                isHolding = False
        balance.append(curBalance)

    for i in balance:
        stdout.write(str(i) + '\n')


main()
SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/017ms11580 KiB
2Time limit exceeded0/01.041s5312 KiB
3Accepted1/117ms11784 KiB
4Accepted1/117ms12004 KiB
5Accepted2/226ms12248 KiB
6Accepted2/294ms14540 KiB
7Accepted2/293ms14352 KiB
8Time limit exceeded0/11.052s6272 KiB
9Time limit exceeded0/11.072s6668 KiB
10Time limit exceeded0/21.059s6404 KiB
11Time limit exceeded0/21.039s6956 KiB
12Time limit exceeded0/21.08s6972 KiB
13Time limit exceeded0/21.055s6852 KiB
14Time limit exceeded0/21.059s7572 KiB
15Time limit exceeded0/31.067s7416 KiB
16Time limit exceeded0/31.064s7544 KiB
17Time limit exceeded0/31.064s7720 KiB
18Time limit exceeded0/31.072s7832 KiB
19Time limit exceeded0/31.072s7840 KiB
20Time limit exceeded0/31.075s7700 KiB
21Time limit exceeded0/31.047s7752 KiB
22Time limit exceeded0/31.072s7732 KiB
23Time limit exceeded0/31.08s7964 KiB
24Time limit exceeded0/31.083s8076 KiB