General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
165223360 Practice:
gotcoding124
1709B - 10 PyPy 3 Accepted 1606 ms 16584 KB 2022-07-21 20:26:43 2022-07-22 13:40:33
→ Source
a,b = map(int,input().split())
l=list(map(int,input().split()))
li1=[0]
li2=[0]
for i in range(a-1):
  li1.append(li1[i]+max(0,l[i]-l[i+1]))
  li2.append(li2[i]+max(0,l[i+1]-l[i]))
for i in range(b):
  x,y = map(int,input().split())
  if(x<y):
    print(li1[y-1]-li1[x-1])
  else:  
    print(li2[x-1]-li2[y-1])  
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details