General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
202796656 Practice:
okay4869
1709B - 11 PyPy 3-64 Accepted 1840 ms 17768 KB 2023-04-20 12:44:34 2023-04-20 12:44:34
→ Source
n,m=map(int,input().split())
a=list(map(int,input().split()))
lf=[0]
lb=[0]
for k in range(n-1):
    lf.append(lf[k]+max(a[k]-a[k+1],0))
    lb.append(lb[k]+max(a[k+1]-a[k],0))
 
for j in range(m):
    s,t=map(int,input().split())
    if t>s:
        print(lf[t-1]-lf[s-1])
    else:
        print(lb[s-1]-lb[t-1])
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details