86212024-01-23 18:46:02pythonMI bróker (50 pont)python3Wrong answer 14/50722ms35832 KiB
def ket():
    N,Q = [int(s) for s in input().split()]
    arak = [int(s) for s in input().split()]
    mini=min(arak)
    maxi=max(arak)
    haszon=0
    vane=False
    for ar in arak:
        if vane:
            if ar==maxi:
                haszon+=maxi
                vane=False
        else:
            if ar==mini:
                haszon-=mini
                vane=True
    for i in range(Q):
        V,E=[int(s) for s in input().split()]
        #kerdesek.append((V,E))
        if V<mini:
            print(0)
            continue
        if E<=maxi:
            print(haszon)
            continue
        if V>=maxi:
            print(-arak[0])
            continue
        print(-mini)
        continue
    
ket()
SubtaskSumTestVerdictTimeMemory
base14/50
1Wrong answer0/017ms11240 KiB
2Wrong answer0/0393ms14040 KiB
3Accepted1/117ms12080 KiB
4Accepted1/117ms12392 KiB
5Wrong answer0/217ms12888 KiB
6Wrong answer0/220ms14796 KiB
7Wrong answer0/221ms14920 KiB
8Accepted1/1657ms16204 KiB
9Accepted1/1643ms18024 KiB
10Accepted2/2674ms19004 KiB
11Accepted2/2634ms20672 KiB
12Accepted2/2632ms21888 KiB
13Accepted2/2697ms22424 KiB
14Accepted2/2629ms24540 KiB
15Wrong answer0/3647ms25504 KiB
16Wrong answer0/3625ms26644 KiB
17Wrong answer0/3695ms27940 KiB
18Wrong answer0/3680ms29220 KiB
19Wrong answer0/3625ms30448 KiB
20Wrong answer0/3620ms31636 KiB
21Wrong answer0/3629ms32564 KiB
22Wrong answer0/3722ms33536 KiB
23Wrong answer0/3708ms34788 KiB
24Wrong answer0/3680ms35832 KiB