6198 | 2023-11-06 18:19:35 | horvathabel | Szemetessor | cpp17 | Accepted 100/100 | 257ms | 12396 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
int n,k;
cin>>n>>k;
vector<ll> s(n+1,0);
vector<ll> l;
for (int i=0;i<n;i++){
int x;
cin>>x;
l.push_back(x);
}
ll ans=0;
for (int i=0; i<k;i++){
ll x,y;
cin>>x>>y;
if (s[x]+y>l[x]){
ans+=l[x]-s[x];
s[x]=y;
}
else s[x]+=y;
}
for (int i=0; i<n;i++) if (s[i]!=0) ans+=l[i]-s[i];
cout<<ans;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1808 KiB | ||||
2 | Accepted | 3ms | 2004 KiB | ||||
subtask2 | 17/17 | ||||||
3 | Accepted | 3ms | 2248 KiB | ||||
4 | Accepted | 3ms | 2492 KiB | ||||
5 | Accepted | 2ms | 2572 KiB | ||||
6 | Accepted | 3ms | 2740 KiB | ||||
7 | Accepted | 3ms | 2952 KiB | ||||
8 | Accepted | 3ms | 3196 KiB | ||||
9 | Accepted | 3ms | 3404 KiB | ||||
10 | Accepted | 2ms | 3456 KiB | ||||
11 | Accepted | 2ms | 3460 KiB | ||||
subtask3 | 25/25 | ||||||
12 | Accepted | 119ms | 3580 KiB | ||||
13 | Accepted | 120ms | 3588 KiB | ||||
14 | Accepted | 133ms | 3592 KiB | ||||
15 | Accepted | 137ms | 4040 KiB | ||||
16 | Accepted | 150ms | 4300 KiB | ||||
17 | Accepted | 200ms | 7492 KiB | ||||
18 | Accepted | 250ms | 11300 KiB | ||||
19 | Accepted | 257ms | 11480 KiB | ||||
20 | Accepted | 250ms | 11416 KiB | ||||
subtask4 | 20/20 | ||||||
21 | Accepted | 125ms | 4576 KiB | ||||
22 | Accepted | 146ms | 6180 KiB | ||||
23 | Accepted | 127ms | 4552 KiB | ||||
24 | Accepted | 146ms | 5372 KiB | ||||
25 | Accepted | 134ms | 4760 KiB | ||||
26 | Accepted | 195ms | 7888 KiB | ||||
27 | Accepted | 247ms | 11492 KiB | ||||
28 | Accepted | 246ms | 11704 KiB | ||||
29 | Accepted | 247ms | 11828 KiB | ||||
30 | Accepted | 216ms | 11832 KiB | ||||
subtask5 | 38/38 | ||||||
31 | Accepted | 3ms | 4796 KiB | ||||
32 | Accepted | 2ms | 4884 KiB | ||||
33 | Accepted | 3ms | 5152 KiB | ||||
34 | Accepted | 3ms | 5072 KiB | ||||
35 | Accepted | 14ms | 5524 KiB | ||||
36 | Accepted | 138ms | 5180 KiB | ||||
37 | Accepted | 254ms | 12352 KiB | ||||
38 | Accepted | 250ms | 12252 KiB | ||||
39 | Accepted | 254ms | 12224 KiB | ||||
40 | Accepted | 252ms | 12396 KiB | ||||
41 | Accepted | 254ms | 12220 KiB | ||||
42 | Accepted | 252ms | 12380 KiB |