96292024-02-23 15:33:29petergalambosMI bróker (50 pont)python3Time limit exceeded 4/501.083s24264 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)]
    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]
    S = [0]*K
    for i in range(K):
        x,y = [int(i) for i in stdin.readline().split()]
        S[i] = P[x][y]
    stdout.write('\n'.join(str(s) for s in S)+'\n')

main()
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/050ms22076 KiB
2Time limit exceeded0/01.057s10132 KiB
3Accepted1/148ms17696 KiB
4Accepted1/150ms20912 KiB
5Accepted2/2207ms24264 KiB
6Time limit exceeded0/21.074s10784 KiB
7Time limit exceeded0/21.072s11016 KiB
8Time limit exceeded0/11.072s8828 KiB
9Time limit exceeded0/11.072s9392 KiB
10Time limit exceeded0/21.083s11168 KiB
11Time limit exceeded0/21.069s10884 KiB
12Time limit exceeded0/21.06s11320 KiB
13Time limit exceeded0/21.06s11568 KiB
14Time limit exceeded0/21.067s11028 KiB
15Time limit exceeded0/31.052s11808 KiB
16Time limit exceeded0/31.057s11948 KiB
17Time limit exceeded0/31.077s11836 KiB
18Time limit exceeded0/31.049s11852 KiB
19Time limit exceeded0/31.049s11912 KiB
20Time limit exceeded0/31.041s11860 KiB
21Time limit exceeded0/31.077s11896 KiB
22Time limit exceeded0/31.06s11808 KiB
23Time limit exceeded0/31.08s11972 KiB
24Time limit exceeded0/31.057s11828 KiB