General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
165142557 Contestant:
Blinov_Artemii
1709B - 10 Python 3 Accepted 1044 ms 9052 KB 2022-07-21 17:44:41 2022-07-22 12:51:06
→ Source
n,m=map(int,input().split())
c=[int(i) for i in input().split()]
f=[0]*n
g=[0]*n
for i in range(1,n):
    f[i]=f[i-1]+max(0,c[i-1]-c[i])
    g[-i-1]=g[-i]+max(0,c[-i]-c[-i-1])
for i in range(m):
    x,y=map(int,input().split())
    if x<y:
        print(f[y-1]-f[x-1])
    else:
        print(g[y-1]-g[x-1])
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details