86222024-01-23 18:47:54pythonMI bróker (50 pont)python3Time limit exceeded 8/501.08s14124 KiB
def brute():
    # O(Q*N)
    N,Q = [int(s) for s in input().split()]
    arak = [int(s) for s in input().split()]
    #kerdesek=[]
    for i in range(Q):
        V,E=[int(s) for s in input().split()]
        #kerdesek.append((V,E))
        db=0
        haszon=0
        for ar in arak:
            if db==0:
                if ar <= V:
                    haszon-=ar
                    db=1
            else:
                if ar >= E:
                    haszon+=ar
                    db=0
            #print(arak,ar,haszon,db)
        print(haszon)
    
    #print()

brute()
SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/017ms11352 KiB
2Time limit exceeded0/01.077s4736 KiB
3Accepted1/117ms11624 KiB
4Accepted1/118ms11732 KiB
5Accepted2/223ms12004 KiB
6Accepted2/268ms13948 KiB
7Accepted2/268ms14124 KiB
8Time limit exceeded0/11.049s5748 KiB
9Time limit exceeded0/11.064s5980 KiB
10Time limit exceeded0/21.054s6056 KiB
11Time limit exceeded0/21.059s6696 KiB
12Time limit exceeded0/21.057s6340 KiB
13Time limit exceeded0/21.055s6084 KiB
14Time limit exceeded0/21.08s6668 KiB
15Time limit exceeded0/31.075s6596 KiB
16Time limit exceeded0/31.072s6888 KiB
17Time limit exceeded0/31.067s6624 KiB
18Time limit exceeded0/31.067s6728 KiB
19Time limit exceeded0/31.072s6888 KiB
20Time limit exceeded0/31.052s7132 KiB
21Time limit exceeded0/31.075s7076 KiB
22Time limit exceeded0/31.064s7080 KiB
23Time limit exceeded0/31.075s7228 KiB
24Time limit exceeded0/31.067s7240 KiB