2374 | 2023-01-11 20:54:23 | 4bs0lute0 | Szemetessor | python3 | Accepted 100/100 | 894ms | 80672 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)
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 18ms | 11884 KiB | ||||
2 | Accepted | 17ms | 12044 KiB | ||||
subtask2 | 17/17 | ||||||
3 | Accepted | 17ms | 12388 KiB | ||||
4 | Accepted | 17ms | 12480 KiB | ||||
5 | Accepted | 17ms | 12836 KiB | ||||
6 | Accepted | 17ms | 12908 KiB | ||||
7 | Accepted | 17ms | 13248 KiB | ||||
8 | Accepted | 17ms | 13384 KiB | ||||
9 | Accepted | 17ms | 13472 KiB | ||||
10 | Accepted | 17ms | 13396 KiB | ||||
11 | Accepted | 17ms | 13872 KiB | ||||
subtask3 | 25/25 | ||||||
12 | Accepted | 536ms | 14048 KiB | ||||
13 | Accepted | 547ms | 14232 KiB | ||||
14 | Accepted | 572ms | 14528 KiB | ||||
15 | Accepted | 565ms | 15236 KiB | ||||
16 | Accepted | 578ms | 17384 KiB | ||||
17 | Accepted | 670ms | 47384 KiB | ||||
18 | Accepted | 772ms | 80516 KiB | ||||
19 | Accepted | 825ms | 80468 KiB | ||||
20 | Accepted | 800ms | 80672 KiB | ||||
subtask4 | 20/20 | ||||||
21 | Accepted | 509ms | 17408 KiB | ||||
22 | Accepted | 597ms | 32160 KiB | ||||
23 | Accepted | 527ms | 17576 KiB | ||||
24 | Accepted | 559ms | 23680 KiB | ||||
25 | Accepted | 517ms | 17592 KiB | ||||
26 | Accepted | 658ms | 46116 KiB | ||||
27 | Accepted | 799ms | 76500 KiB | ||||
28 | Accepted | 750ms | 76836 KiB | ||||
29 | Accepted | 801ms | 76784 KiB | ||||
30 | Accepted | 745ms | 77892 KiB | ||||
subtask5 | 38/38 | ||||||
31 | Accepted | 17ms | 14608 KiB | ||||
32 | Accepted | 17ms | 14776 KiB | ||||
33 | Accepted | 17ms | 14656 KiB | ||||
34 | Accepted | 17ms | 14804 KiB | ||||
35 | Accepted | 50ms | 17908 KiB | ||||
36 | Accepted | 563ms | 15340 KiB | ||||
37 | Accepted | 782ms | 77444 KiB | ||||
38 | Accepted | 796ms | 77432 KiB | ||||
39 | Accepted | 816ms | 77532 KiB | ||||
40 | Accepted | 870ms | 77356 KiB | ||||
41 | Accepted | 832ms | 77440 KiB | ||||
42 | Accepted | 894ms | 77416 KiB |