96262024-02-23 15:26:39petergalambosMI bróker (50 pont)python3Time limit exceeded 4/501.1s24224 KiB
from sys import stdin,stdout

def main():
    N, K = [int(i) for i in input().split()]
    A = [int(i) for i in 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 input().split()]
        print(P[x][y])

main()
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/052ms22220 KiB
2Time limit exceeded0/01.077s10116 KiB
3Accepted1/148ms17648 KiB
4Accepted1/150ms20956 KiB
5Accepted2/2207ms24224 KiB
6Time limit exceeded0/21.049s10816 KiB
7Time limit exceeded0/21.064s11088 KiB
8Time limit exceeded0/11.047s9180 KiB
9Time limit exceeded0/11.085s9400 KiB
10Time limit exceeded0/21.067s11344 KiB
11Time limit exceeded0/21.069s11120 KiB
12Time limit exceeded0/21.052s11404 KiB
13Time limit exceeded0/21.065s11628 KiB
14Time limit exceeded0/21.052s11420 KiB
15Time limit exceeded0/31.044s12364 KiB
16Time limit exceeded0/31.08s12424 KiB
17Time limit exceeded0/31.072s12524 KiB
18Time limit exceeded0/31.059s12448 KiB
19Time limit exceeded0/31.072s12608 KiB
20Time limit exceeded0/31.1s12516 KiB
21Time limit exceeded0/31.072s12504 KiB
22Time limit exceeded0/31.044s12492 KiB
23Time limit exceeded0/31.065s12560 KiB
24Time limit exceeded0/31.083s12496 KiB