3518 | 2023-02-28 16:18:15 | Tina0731 | Szemetessor | cpp11 | Accepted 100/100 | 256ms | 17140 KiB |
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long int n, k;
cin>>n>>k;
long long int c[n];
for(int i=0;i<n;i++)
{
cin>>c[i];
//cout<<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 | 2000 KiB | ||||
subtask2 | 17/17 | ||||||
3 | Accepted | 3ms | 2212 KiB | ||||
4 | Accepted | 3ms | 2420 KiB | ||||
5 | Accepted | 3ms | 2548 KiB | ||||
6 | Accepted | 3ms | 2764 KiB | ||||
7 | Accepted | 3ms | 2968 KiB | ||||
8 | Accepted | 3ms | 3184 KiB | ||||
9 | Accepted | 2ms | 3268 KiB | ||||
10 | Accepted | 3ms | 3512 KiB | ||||
11 | Accepted | 3ms | 3720 KiB | ||||
subtask3 | 25/25 | ||||||
12 | Accepted | 123ms | 10296 KiB | ||||
13 | Accepted | 122ms | 10580 KiB | ||||
14 | Accepted | 136ms | 10440 KiB | ||||
15 | Accepted | 141ms | 10388 KiB | ||||
16 | Accepted | 151ms | 10664 KiB | ||||
17 | Accepted | 202ms | 13476 KiB | ||||
18 | Accepted | 246ms | 16584 KiB | ||||
19 | Accepted | 246ms | 16764 KiB | ||||
20 | Accepted | 246ms | 17016 KiB | ||||
subtask4 | 20/20 | ||||||
21 | Accepted | 127ms | 11064 KiB | ||||
22 | Accepted | 149ms | 12564 KiB | ||||
23 | Accepted | 127ms | 11108 KiB | ||||
24 | Accepted | 150ms | 11628 KiB | ||||
25 | Accepted | 135ms | 11132 KiB | ||||
26 | Accepted | 197ms | 13980 KiB | ||||
27 | Accepted | 243ms | 16760 KiB | ||||
28 | Accepted | 245ms | 16944 KiB | ||||
29 | Accepted | 246ms | 17012 KiB | ||||
30 | Accepted | 216ms | 17032 KiB | ||||
subtask5 | 38/38 | ||||||
31 | Accepted | 3ms | 4652 KiB | ||||
32 | Accepted | 2ms | 4620 KiB | ||||
33 | Accepted | 3ms | 4652 KiB | ||||
34 | Accepted | 3ms | 4636 KiB | ||||
35 | Accepted | 14ms | 5300 KiB | ||||
36 | Accepted | 150ms | 10896 KiB | ||||
37 | Accepted | 247ms | 17128 KiB | ||||
38 | Accepted | 248ms | 17012 KiB | ||||
39 | Accepted | 248ms | 17016 KiB | ||||
40 | Accepted | 248ms | 17020 KiB | ||||
41 | Accepted | 248ms | 17140 KiB | ||||
42 | Accepted | 256ms | 17140 KiB |