General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
223729968 Practice:
HuangYS
1709B - 11 Python 3 Accepted 826 ms 18312 KB 2023-09-17 16:12:09 2023-09-17 16:12:09
→ 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