23742023-01-11 20:54:234bs0lute0Szemetessorpython3Accepted 100/100894ms80672 KiB
#import sys

#sys.stdin = open("input1.txt")
N, K = map(int, input().split())
C = list(map(int, input().split()))
B = {}
ar = 0
for i in range(N):
    B[i] = 0
for i in range(K):
    t = list(map(int, input().split()))
    if B[t[0]]+t[1] > C[t[0]]:
        ar += C[t[0]] - B[t[0]]
        B[t[0]] = 0
    B[t[0]] += t[1]
for i in range(N):
    if B[i] > 0:
        ar += C[i] - B[i]
print(ar)
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted18ms11884 KiB
2Accepted17ms12044 KiB
subtask217/17
3Accepted17ms12388 KiB
4Accepted17ms12480 KiB
5Accepted17ms12836 KiB
6Accepted17ms12908 KiB
7Accepted17ms13248 KiB
8Accepted17ms13384 KiB
9Accepted17ms13472 KiB
10Accepted17ms13396 KiB
11Accepted17ms13872 KiB
subtask325/25
12Accepted536ms14048 KiB
13Accepted547ms14232 KiB
14Accepted572ms14528 KiB
15Accepted565ms15236 KiB
16Accepted578ms17384 KiB
17Accepted670ms47384 KiB
18Accepted772ms80516 KiB
19Accepted825ms80468 KiB
20Accepted800ms80672 KiB
subtask420/20
21Accepted509ms17408 KiB
22Accepted597ms32160 KiB
23Accepted527ms17576 KiB
24Accepted559ms23680 KiB
25Accepted517ms17592 KiB
26Accepted658ms46116 KiB
27Accepted799ms76500 KiB
28Accepted750ms76836 KiB
29Accepted801ms76784 KiB
30Accepted745ms77892 KiB
subtask538/38
31Accepted17ms14608 KiB
32Accepted17ms14776 KiB
33Accepted17ms14656 KiB
34Accepted17ms14804 KiB
35Accepted50ms17908 KiB
36Accepted563ms15340 KiB
37Accepted782ms77444 KiB
38Accepted796ms77432 KiB
39Accepted816ms77532 KiB
40Accepted870ms77356 KiB
41Accepted832ms77440 KiB
42Accepted894ms77416 KiB