10852 | 2024-04-16 17:16:09 | turitamas | Szemetessor | cpp17 | Accepted 100/100 | 252ms | 16980 KiB |
#include <iostream>
using namespace std;
int main()
{
int n, k;
cin>>n>>k;
long long int c[n]={0};
long long int m[n]={0};
long long int t[k][2];
long long int a=0;
for(int i=0; i<n; i++)
{
cin>>c[i];
}
for(int i=0; i<k; i++)
{
for(int j=0; j<2; j++)
{
cin>>t[i][j];
}
}
for(int i=0; i<k; i++)
{
if(c[t[i][0]]>=t[i][1]+m[t[i][0]])
{
m[t[i][0]]+=t[i][1];
}
else if(c[t[i][0]]<t[i][1]+m[t[i][0]])
{
a+=c[t[i][0]]-m[t[i][0]];
m[t[i][0]]=t[i][1];
}
}
for(int i=0; i<n; i++)
{
if(m[i]!=0)
a+=(c[i]-m[i]);
}
cout<<a;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1748 KiB | ||||
2 | Accepted | 3ms | 1996 KiB | ||||
subtask2 | 17/17 | ||||||
3 | Accepted | 3ms | 2120 KiB | ||||
4 | Accepted | 2ms | 2204 KiB | ||||
5 | Accepted | 3ms | 2336 KiB | ||||
6 | Accepted | 3ms | 2580 KiB | ||||
7 | Accepted | 3ms | 2772 KiB | ||||
8 | Accepted | 3ms | 2984 KiB | ||||
9 | Accepted | 2ms | 3096 KiB | ||||
10 | Accepted | 3ms | 3196 KiB | ||||
11 | Accepted | 3ms | 3280 KiB | ||||
subtask3 | 25/25 | ||||||
12 | Accepted | 120ms | 9476 KiB | ||||
13 | Accepted | 122ms | 9796 KiB | ||||
14 | Accepted | 135ms | 9700 KiB | ||||
15 | Accepted | 140ms | 9820 KiB | ||||
16 | Accepted | 151ms | 10308 KiB | ||||
17 | Accepted | 201ms | 13220 KiB | ||||
18 | Accepted | 247ms | 16352 KiB | ||||
19 | Accepted | 246ms | 16352 KiB | ||||
20 | Accepted | 247ms | 16352 KiB | ||||
subtask4 | 20/20 | ||||||
21 | Accepted | 127ms | 10696 KiB | ||||
22 | Accepted | 146ms | 11912 KiB | ||||
23 | Accepted | 128ms | 10956 KiB | ||||
24 | Accepted | 148ms | 11396 KiB | ||||
25 | Accepted | 134ms | 10912 KiB | ||||
26 | Accepted | 197ms | 13748 KiB | ||||
27 | Accepted | 240ms | 16464 KiB | ||||
28 | Accepted | 245ms | 16660 KiB | ||||
29 | Accepted | 244ms | 16724 KiB | ||||
30 | Accepted | 212ms | 16840 KiB | ||||
subtask5 | 38/38 | ||||||
31 | Accepted | 3ms | 4452 KiB | ||||
32 | Accepted | 3ms | 4480 KiB | ||||
33 | Accepted | 3ms | 4452 KiB | ||||
34 | Accepted | 3ms | 4384 KiB | ||||
35 | Accepted | 14ms | 4948 KiB | ||||
36 | Accepted | 141ms | 10584 KiB | ||||
37 | Accepted | 248ms | 16808 KiB | ||||
38 | Accepted | 252ms | 16764 KiB | ||||
39 | Accepted | 250ms | 16704 KiB | ||||
40 | Accepted | 250ms | 16980 KiB | ||||
41 | Accepted | 248ms | 16952 KiB | ||||
42 | Accepted | 248ms | 16936 KiB |