96332024-02-23 15:50:36petergalambosMI bróker (50 pont)python3Time limit exceeded 4/501.08s24572 KiB
from sys import stdin,stdout

def main():
    N, K = map(int, stdin.readline().split())
    A = list(map(int, stdin.readline().split()))
    maxi = 501
    P = [[0]*512 for i in range(512)]
    for i in range(1,maxi):
        m = maxi
        for x in A:
            if (i >= x):
                P[i][i+1] -= x
                P[i][m] += x
                m = i+1
            elif (x >= m):
                P[i][m] += x
                P[i][x+1] -= x
                m = x+1
        for j in range(i+1,maxi):
            P[i][j] += P[i][j-1]
            
    S = [0]*K
    for index,i in enumerate(stdin.readlines()):
        x,y = map(int,i.split())
        S[index] = P[x][y]
        
    stdout.write('\n'.join(str(s) for s in S)+'\n')

main()
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/050ms22264 KiB
2Time limit exceeded0/01.052s10128 KiB
3Accepted1/148ms17920 KiB
4Accepted1/150ms21280 KiB
5Accepted2/2209ms24572 KiB
6Time limit exceeded0/21.07s10984 KiB
7Time limit exceeded0/21.052s10972 KiB
8Time limit exceeded0/11.08s9064 KiB
9Time limit exceeded0/11.064s9396 KiB
10Time limit exceeded0/21.065s11540 KiB
11Time limit exceeded0/21.072s10884 KiB
12Time limit exceeded0/21.069s11624 KiB
13Time limit exceeded0/21.036s11548 KiB
14Time limit exceeded0/21.072s11192 KiB
15Time limit exceeded0/31.065s11824 KiB
16Time limit exceeded0/31.049s11888 KiB
17Time limit exceeded0/31.044s11756 KiB
18Time limit exceeded0/31.049s12144 KiB
19Time limit exceeded0/31.075s12060 KiB
20Time limit exceeded0/31.055s12040 KiB
21Time limit exceeded0/31.075s12324 KiB
22Time limit exceeded0/31.064s12124 KiB
23Time limit exceeded0/31.075s12216 KiB
24Time limit exceeded0/31.065s12216 KiB