6083 | 2023-10-29 17:18:14 | tomi7 | Szemetessor | cpp11 | Accepted 100/100 | 256ms | 7888 KiB |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
vector<int> C(N);
for(int i = 0; i < N; i++){
cin >> C[i];
}
vector<int> teli(N);
long long ar = 0;
for(int i = 0; i < K; i++){
int T, Q;
cin >> T >> Q;
if(teli[T] + Q > C[T]){
ar += C[T] - teli[T];
teli[T] = 0;
}
teli[T] += Q;
}
for(int i = 0; i < N; i++){
if(teli[i] > 0){
ar += C[i] - teli[i];
}
}
cout << ar << "\n";
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1816 KiB | ||||
2 | Accepted | 3ms | 2004 KiB | ||||
subtask2 | 17/17 | ||||||
3 | Accepted | 3ms | 2212 KiB | ||||
4 | Accepted | 3ms | 2428 KiB | ||||
5 | Accepted | 3ms | 2672 KiB | ||||
6 | Accepted | 2ms | 2788 KiB | ||||
7 | Accepted | 2ms | 2872 KiB | ||||
8 | Accepted | 3ms | 2856 KiB | ||||
9 | Accepted | 3ms | 3064 KiB | ||||
10 | Accepted | 2ms | 3152 KiB | ||||
11 | Accepted | 2ms | 3144 KiB | ||||
subtask3 | 25/25 | ||||||
12 | Accepted | 120ms | 3396 KiB | ||||
13 | Accepted | 120ms | 3516 KiB | ||||
14 | Accepted | 135ms | 3616 KiB | ||||
15 | Accepted | 140ms | 3632 KiB | ||||
16 | Accepted | 152ms | 3792 KiB | ||||
17 | Accepted | 202ms | 5108 KiB | ||||
18 | Accepted | 250ms | 6720 KiB | ||||
19 | Accepted | 250ms | 6716 KiB | ||||
20 | Accepted | 250ms | 7036 KiB | ||||
subtask4 | 20/20 | ||||||
21 | Accepted | 125ms | 4524 KiB | ||||
22 | Accepted | 146ms | 5196 KiB | ||||
23 | Accepted | 129ms | 4696 KiB | ||||
24 | Accepted | 148ms | 5152 KiB | ||||
25 | Accepted | 136ms | 4856 KiB | ||||
26 | Accepted | 197ms | 6284 KiB | ||||
27 | Accepted | 245ms | 7788 KiB | ||||
28 | Accepted | 246ms | 7832 KiB | ||||
29 | Accepted | 247ms | 7720 KiB | ||||
30 | Accepted | 215ms | 7724 KiB | ||||
subtask5 | 38/38 | ||||||
31 | Accepted | 3ms | 4884 KiB | ||||
32 | Accepted | 3ms | 4808 KiB | ||||
33 | Accepted | 3ms | 4808 KiB | ||||
34 | Accepted | 3ms | 4960 KiB | ||||
35 | Accepted | 14ms | 4912 KiB | ||||
36 | Accepted | 141ms | 4836 KiB | ||||
37 | Accepted | 254ms | 7836 KiB | ||||
38 | Accepted | 256ms | 7888 KiB | ||||
39 | Accepted | 252ms | 7788 KiB | ||||
40 | Accepted | 252ms | 7788 KiB | ||||
41 | Accepted | 252ms | 7788 KiB | ||||
42 | Accepted | 252ms | 7860 KiB |