96282024-02-23 15:30:28petergalambosMI bróker (50 pont)python3Time limit exceeded 4/501.088s23960 KiB
from sys import stdin,stdout

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

main()
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/050ms21896 KiB
2Time limit exceeded0/01.062s10124 KiB
3Accepted1/148ms17400 KiB
4Accepted1/150ms20968 KiB
5Accepted2/2209ms23960 KiB
6Time limit exceeded0/21.06s10536 KiB
7Time limit exceeded0/21.047s10560 KiB
8Time limit exceeded0/11.075s8596 KiB
9Time limit exceeded0/11.067s9096 KiB
10Time limit exceeded0/21.085s11204 KiB
11Time limit exceeded0/21.08s10416 KiB
12Time limit exceeded0/21.065s11168 KiB
13Time limit exceeded0/21.069s11436 KiB
14Time limit exceeded0/21.065s11156 KiB
15Time limit exceeded0/31.06s11884 KiB
16Time limit exceeded0/31.049s12088 KiB
17Time limit exceeded0/31.08s12392 KiB
18Time limit exceeded0/31.06s12264 KiB
19Time limit exceeded0/31.08s12428 KiB
20Time limit exceeded0/31.088s12776 KiB
21Time limit exceeded0/31.069s12896 KiB
22Time limit exceeded0/31.08s12644 KiB
23Time limit exceeded0/31.057s12716 KiB
24Time limit exceeded0/31.036s12676 KiB