27432023-01-20 15:32:44kristofSzemetessorpython3Accepted 100/100699ms63788 KiB
N, M = input().split()
N = int(N)
M = int(M)

avo = 0

lista = [0 for i in range(N)]

MaxErtekLista = list(map(int, input().split()))

for i in range(M):
    index, value = input().split()
    index = int(index)
    value = int(value)
    
    if lista[index] + value > MaxErtekLista[index]:
        avo += MaxErtekLista[index] - lista[index]
        lista[index] = value
    else:
        lista[index] += value


for i in range(N):
    if lista[i] % MaxErtekLista[i] == 0:
        pass
    else:    
        avo += MaxErtekLista[i] - lista[i] % MaxErtekLista[i] 

print(avo)
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted18ms11312 KiB
2Accepted17ms11588 KiB
subtask217/17
3Accepted17ms11428 KiB
4Accepted17ms12000 KiB
5Accepted17ms12008 KiB
6Accepted17ms12152 KiB
7Accepted17ms12556 KiB
8Accepted17ms12600 KiB
9Accepted17ms12600 KiB
10Accepted17ms12696 KiB
11Accepted17ms13168 KiB
subtask325/25
12Accepted412ms12940 KiB
13Accepted446ms13380 KiB
14Accepted439ms13532 KiB
15Accepted435ms14084 KiB
16Accepted435ms16052 KiB
17Accepted560ms37448 KiB
18Accepted657ms61272 KiB
19Accepted653ms61352 KiB
20Accepted699ms61556 KiB
subtask420/20
21Accepted414ms16100 KiB
22Accepted467ms26372 KiB
23Accepted432ms16432 KiB
24Accepted439ms19816 KiB
25Accepted421ms16384 KiB
26Accepted504ms37540 KiB
27Accepted614ms59236 KiB
28Accepted639ms60380 KiB
29Accepted637ms60560 KiB
30Accepted595ms63788 KiB
subtask538/38
31Accepted17ms13996 KiB
32Accepted16ms14080 KiB
33Accepted17ms13820 KiB
34Accepted18ms13740 KiB
35Accepted45ms16456 KiB
36Accepted432ms13944 KiB
37Accepted593ms61704 KiB
38Accepted592ms61856 KiB
39Accepted588ms61968 KiB
40Accepted629ms61952 KiB
41Accepted612ms61992 KiB
42Accepted637ms62088 KiB