95792024-02-23 12:10:57KezdőMI bróker (50 pont)python3Time limit exceeded 8/501.083s14544 KiB
from sys import stdin,stdout

def main():
    N,Q = [int(i) for i in input().split()]
    ar = [int(i) for i in stdin.readline().split()]

    def haszon(V,E):
        H = 0
        van = False
        for a in ar:
            if not van and a <= V:
                H -= a
                van = True
            if van and a >= E:
                H += a
                van = False
##        print(H)
        stdout.write(str(H)+'\n')
   
    for i in range(Q):
        V,E = [int(i) for i in stdin.readline().split()]
        haszon(V,E)

main()
SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/017ms11280 KiB
2Time limit exceeded0/01.064s4984 KiB
3Accepted1/117ms11760 KiB
4Accepted1/117ms11784 KiB
5Accepted2/223ms12196 KiB
6Accepted2/264ms14060 KiB
7Accepted2/264ms14544 KiB
8Time limit exceeded0/11.072s6160 KiB
9Time limit exceeded0/11.08s6356 KiB
10Time limit exceeded0/21.064s6104 KiB
11Time limit exceeded0/21.083s6588 KiB
12Time limit exceeded0/21.059s6880 KiB
13Time limit exceeded0/21.065s6592 KiB
14Time limit exceeded0/21.067s7184 KiB
15Time limit exceeded0/31.064s7436 KiB
16Time limit exceeded0/31.057s7480 KiB
17Time limit exceeded0/31.075s7432 KiB
18Time limit exceeded0/31.049s7500 KiB
19Time limit exceeded0/31.072s7748 KiB
20Time limit exceeded0/31.069s7800 KiB
21Time limit exceeded0/31.08s7884 KiB
22Time limit exceeded0/31.059s7920 KiB
23Time limit exceeded0/31.072s8072 KiB
24Time limit exceeded0/31.044s7864 KiB