11662 | 2024-11-04 11:45:34 | bzy | Szemetessor | cpp17 | Accepted 100/100 | 259ms | 1980 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int n, k; cin >> n >> k;
vector <int> C(n);
for(int &c : C) cin >> c;
ll ans = 0;
vector <int> K(n, 0);
for(int i = 0; i < k; i++){
int t, q; cin >> t >> q;
if(K[t] + q <= C[t]) K[t] += q;
else{
ans += C[t] - K[t];
K[t] = q;
}
}
for(int i = 0; i < n; i++) if(K[i] > 0) ans += C[i] - K[i];
cout << ans;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 1ms | 320 KiB | ||||
2 | Accepted | 1ms | 320 KiB | ||||
subtask2 | 17/17 | ||||||
3 | Accepted | 1ms | 320 KiB | ||||
4 | Accepted | 1ms | 320 KiB | ||||
5 | Accepted | 1ms | 320 KiB | ||||
6 | Accepted | 1ms | 320 KiB | ||||
7 | Accepted | 1ms | 320 KiB | ||||
8 | Accepted | 1ms | 320 KiB | ||||
9 | Accepted | 1ms | 532 KiB | ||||
10 | Accepted | 1ms | 388 KiB | ||||
11 | Accepted | 1ms | 500 KiB | ||||
subtask3 | 25/25 | ||||||
12 | Accepted | 120ms | 508 KiB | ||||
13 | Accepted | 122ms | 404 KiB | ||||
14 | Accepted | 135ms | 412 KiB | ||||
15 | Accepted | 141ms | 420 KiB | ||||
16 | Accepted | 153ms | 476 KiB | ||||
17 | Accepted | 203ms | 1064 KiB | ||||
18 | Accepted | 259ms | 1968 KiB | ||||
19 | Accepted | 259ms | 1968 KiB | ||||
20 | Accepted | 256ms | 1972 KiB | ||||
subtask4 | 20/20 | ||||||
21 | Accepted | 126ms | 512 KiB | ||||
22 | Accepted | 148ms | 808 KiB | ||||
23 | Accepted | 127ms | 476 KiB | ||||
24 | Accepted | 150ms | 568 KiB | ||||
25 | Accepted | 137ms | 476 KiB | ||||
26 | Accepted | 200ms | 1060 KiB | ||||
27 | Accepted | 252ms | 1668 KiB | ||||
28 | Accepted | 252ms | 1952 KiB | ||||
29 | Accepted | 250ms | 1696 KiB | ||||
30 | Accepted | 216ms | 1848 KiB | ||||
subtask5 | 38/38 | ||||||
31 | Accepted | 1ms | 508 KiB | ||||
32 | Accepted | 1ms | 320 KiB | ||||
33 | Accepted | 1ms | 320 KiB | ||||
34 | Accepted | 2ms | 320 KiB | ||||
35 | Accepted | 13ms | 440 KiB | ||||
36 | Accepted | 142ms | 408 KiB | ||||
37 | Accepted | 256ms | 1980 KiB | ||||
38 | Accepted | 256ms | 1972 KiB | ||||
39 | Accepted | 256ms | 1972 KiB | ||||
40 | Accepted | 256ms | 1848 KiB | ||||
41 | Accepted | 254ms | 1848 KiB | ||||
42 | Accepted | 256ms | 1972 KiB |