96302024-02-23 15:37:16petergalambosMI 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 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]
    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/050ms22268 KiB
2Time limit exceeded0/01.049s10068 KiB
3Accepted1/148ms17960 KiB
4Accepted1/150ms21132 KiB
5Accepted2/2207ms24572 KiB
6Time limit exceeded0/21.021s11004 KiB
7Time limit exceeded0/21.049s10780 KiB
8Time limit exceeded0/11.057s8984 KiB
9Time limit exceeded0/11.069s9180 KiB
10Time limit exceeded0/21.067s11352 KiB
11Time limit exceeded0/21.065s10608 KiB
12Time limit exceeded0/21.065s11144 KiB
13Time limit exceeded0/21.072s11344 KiB
14Time limit exceeded0/21.052s11124 KiB
15Time limit exceeded0/31.08s12116 KiB
16Time limit exceeded0/31.044s12192 KiB
17Time limit exceeded0/31.077s12248 KiB
18Time limit exceeded0/31.064s12060 KiB
19Time limit exceeded0/31.067s12320 KiB
20Time limit exceeded0/31.06s12588 KiB
21Time limit exceeded0/31.049s12764 KiB
22Time limit exceeded0/31.044s12700 KiB
23Time limit exceeded0/31.057s12816 KiB
24Time limit exceeded0/31.049s12792 KiB