10845 | 2024-04-16 16:17:34 | TheViktor | Szemetessor | cpp17 | Accepted 100/100 | 270ms | 17684 KiB |
#include <iostream>
using namespace std;
int main()
{
int n, k;
cin>>n>>k;
long long int c[n];
for(int i=0;i<n;i++)
{
cin>>c[i];
}
long long int nap[k][2];
for(int j=0;j<k; j++)
cin>>nap[j][0]>>nap[j][1];
long long int ar=0;
long long int sz[n];
for(int i=0;i<n;i++)
sz[i]=0;
long long int i, x;
for(int j=0;j<k; j++)
{
i=nap[j][0];
x=nap[j][1];
if(sz[i]+x<=c[i])
sz[i]+=x;
else
{
ar=ar+c[i]-sz[i];
sz[i]=x;
}
}
for(i=0;i<n;i++)
{
if(sz[i]!=0)
ar=ar+c[i]-sz[i];
}
cout<<ar;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1744 KiB | ||||
2 | Accepted | 3ms | 1996 KiB | ||||
subtask2 | 17/17 | ||||||
3 | Accepted | 3ms | 2212 KiB | ||||
4 | Accepted | 3ms | 2288 KiB | ||||
5 | Accepted | 2ms | 2292 KiB | ||||
6 | Accepted | 3ms | 2532 KiB | ||||
7 | Accepted | 2ms | 2616 KiB | ||||
8 | Accepted | 3ms | 2640 KiB | ||||
9 | Accepted | 2ms | 2756 KiB | ||||
10 | Accepted | 3ms | 3068 KiB | ||||
11 | Accepted | 3ms | 3204 KiB | ||||
subtask3 | 25/25 | ||||||
12 | Accepted | 128ms | 9736 KiB | ||||
13 | Accepted | 128ms | 9976 KiB | ||||
14 | Accepted | 143ms | 9936 KiB | ||||
15 | Accepted | 149ms | 9848 KiB | ||||
16 | Accepted | 165ms | 10096 KiB | ||||
17 | Accepted | 215ms | 13036 KiB | ||||
18 | Accepted | 268ms | 16164 KiB | ||||
19 | Accepted | 270ms | 16428 KiB | ||||
20 | Accepted | 270ms | 16604 KiB | ||||
subtask4 | 20/20 | ||||||
21 | Accepted | 134ms | 10716 KiB | ||||
22 | Accepted | 157ms | 11912 KiB | ||||
23 | Accepted | 136ms | 10700 KiB | ||||
24 | Accepted | 158ms | 11400 KiB | ||||
25 | Accepted | 144ms | 11008 KiB | ||||
26 | Accepted | 211ms | 13848 KiB | ||||
27 | Accepted | 263ms | 16736 KiB | ||||
28 | Accepted | 263ms | 16976 KiB | ||||
29 | Accepted | 263ms | 16944 KiB | ||||
30 | Accepted | 230ms | 17304 KiB | ||||
subtask5 | 38/38 | ||||||
31 | Accepted | 3ms | 4856 KiB | ||||
32 | Accepted | 3ms | 4940 KiB | ||||
33 | Accepted | 3ms | 5064 KiB | ||||
34 | Accepted | 3ms | 4952 KiB | ||||
35 | Accepted | 14ms | 5616 KiB | ||||
36 | Accepted | 150ms | 11260 KiB | ||||
37 | Accepted | 270ms | 17420 KiB | ||||
38 | Accepted | 268ms | 17676 KiB | ||||
39 | Accepted | 270ms | 17684 KiB | ||||
40 | Accepted | 270ms | 17632 KiB | ||||
41 | Accepted | 270ms | 17548 KiB | ||||
42 | Accepted | 270ms | 17556 KiB |