86402024-01-24 17:18:49NagyLeoMI bróker (50 pont)pypy3Time limit exceeded 8/501.067s89460 KiB
from sys import stdin, stdout
input=stdin.readline

def main():
    N,Q = list(map(int, input().split()))
    # N,Q = [int(x) for x in input().split()]

    Prices = list(map(int, stdin.readline().split()))

    for i in range(Q):
        isHolding = False
        curBalance = 0
        lo,hi = list(map(int, stdin.readline().split()))
        for f in Prices:
            if not isHolding:
                if lo >= f:
                    curBalance -= f
                    isHolding = True
            elif hi <= f:
                curBalance += f
                isHolding = False

        stdout.write(str(curBalance) + '\n')


main()
SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/039ms76596 KiB
2Time limit exceeded0/01.067s25692 KiB
3Accepted1/143ms77164 KiB
4Accepted1/139ms77660 KiB
5Accepted2/250ms87660 KiB
6Accepted2/259ms88780 KiB
7Accepted2/259ms89460 KiB
8Time limit exceeded0/11.047s27292 KiB
9Time limit exceeded0/11.05s28272 KiB
10Time limit exceeded0/21.039s27252 KiB
11Time limit exceeded0/21.034s27132 KiB
12Time limit exceeded0/21.047s27436 KiB
13Time limit exceeded0/21.059s27232 KiB
14Time limit exceeded0/21.067s27108 KiB
15Time limit exceeded0/31.047s27560 KiB
16Time limit exceeded0/31.062s27556 KiB
17Time limit exceeded0/31.059s27644 KiB
18Time limit exceeded0/31.059s28100 KiB
19Time limit exceeded0/31.036s27944 KiB
20Time limit exceeded0/31.05s28132 KiB
21Time limit exceeded0/31.042s28268 KiB
22Time limit exceeded0/31.041s28660 KiB
23Time limit exceeded0/31.065s28368 KiB
24Time limit exceeded0/31.054s28084 KiB