96322024-02-23 15:46:36petergalambosMI bróker (50 pont)python3Time limit exceeded 4/501.1s24716 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/054ms22288 KiB
2Time limit exceeded0/01.082s10212 KiB
3Accepted1/148ms18164 KiB
4Accepted1/150ms21408 KiB
5Accepted2/2209ms24716 KiB
6Time limit exceeded0/21.054s10776 KiB
7Time limit exceeded0/21.088s10824 KiB
8Time limit exceeded0/11.064s8828 KiB
9Time limit exceeded0/11.06s8948 KiB
10Time limit exceeded0/21.055s11020 KiB
11Time limit exceeded0/21.077s10636 KiB
12Time limit exceeded0/21.044s11368 KiB
13Time limit exceeded0/21.072s11856 KiB
14Time limit exceeded0/21.055s11424 KiB
15Time limit exceeded0/31.069s12324 KiB
16Time limit exceeded0/31.08s12484 KiB
17Time limit exceeded0/31.1s12196 KiB
18Time limit exceeded0/31.06s12304 KiB
19Time limit exceeded0/31.049s12332 KiB
20Time limit exceeded0/31.049s12532 KiB
21Time limit exceeded0/31.077s12676 KiB
22Time limit exceeded0/31.054s12640 KiB
23Time limit exceeded0/31.065s12636 KiB
24Time limit exceeded0/31.052s12632 KiB