95832024-02-23 12:17:01KezdőMI bróker (50 pont)python3Time limit exceeded 8/501.08s14468 KiB
from sys import stdin,stdout

def haszon(V,E,ar):
    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')

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

    for i in range(Q):
        V,E = [int(i) for i in stdin.readline().split()]
        haszon(V,E,ar)

main()
SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/018ms11308 KiB
2Time limit exceeded0/01.052s4912 KiB
3Accepted1/117ms11948 KiB
4Accepted1/117ms12228 KiB
5Accepted2/223ms12448 KiB
6Accepted2/264ms14192 KiB
7Accepted2/264ms14468 KiB
8Time limit exceeded0/11.044s6036 KiB
9Time limit exceeded0/11.055s6168 KiB
10Time limit exceeded0/21.047s6212 KiB
11Time limit exceeded0/21.072s6564 KiB
12Time limit exceeded0/21.069s6580 KiB
13Time limit exceeded0/21.057s6220 KiB
14Time limit exceeded0/21.06s6720 KiB
15Time limit exceeded0/31.075s6816 KiB
16Time limit exceeded0/31.08s6668 KiB
17Time limit exceeded0/31.06s6944 KiB
18Time limit exceeded0/31.065s7240 KiB
19Time limit exceeded0/31.075s7332 KiB
20Time limit exceeded0/31.072s7368 KiB
21Time limit exceeded0/31.064s7404 KiB
22Time limit exceeded0/31.067s7296 KiB
23Time limit exceeded0/31.064s7584 KiB
24Time limit exceeded0/31.067s7588 KiB