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

def main():
    N, K = [int(i) for i in stdin.readline().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 stdin.readline().split()]
        stdout.write(str(P[x][y])+'\n')

main()
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/052ms21984 KiB
2Time limit exceeded0/01.07s10052 KiB
3Accepted1/146ms17504 KiB
4Accepted1/150ms21188 KiB
5Accepted2/2206ms24072 KiB
6Time limit exceeded0/21.057s10328 KiB
7Time limit exceeded0/21.08s10528 KiB
8Time limit exceeded0/11.039s8360 KiB
9Time limit exceeded0/11.065s8840 KiB
10Time limit exceeded0/21.049s10532 KiB
11Time limit exceeded0/21.044s9956 KiB
12Time limit exceeded0/21.06s10544 KiB
13Time limit exceeded0/21.065s10780 KiB
14Time limit exceeded0/21.065s10240 KiB
15Time limit exceeded0/31.072s11256 KiB
16Time limit exceeded0/31.065s11416 KiB
17Time limit exceeded0/31.072s11592 KiB
18Time limit exceeded0/31.069s11820 KiB
19Time limit exceeded0/31.088s11888 KiB
20Time limit exceeded0/31.08s11828 KiB
21Time limit exceeded0/31.06s11760 KiB
22Time limit exceeded0/31.06s11756 KiB
23Time limit exceeded0/31.088s11992 KiB
24Time limit exceeded0/31.072s12132 KiB