108442024-04-16 16:16:57TheViktorSzemetessorcpp17Wrong answer 17/100261ms10788 KiB
#include <iostream>
using namespace std;

int main()
{
    int n, k;
    cin>>n>>k;
    int c[n];
    for(int i=0;i<n;i++)
    {
        cin>>c[i];
    }
    int nap[k][2];
    for(int j=0;j<k; j++)
        cin>>nap[j][0]>>nap[j][1];

    int ar=0;
    int sz[n];
    for(int i=0;i<n;i++)
        sz[i]=0;
    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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1748 KiB
2Accepted3ms1908 KiB
subtask217/17
3Accepted3ms2120 KiB
4Accepted3ms2336 KiB
5Accepted3ms2548 KiB
6Accepted2ms2668 KiB
7Accepted3ms2904 KiB
8Accepted2ms2876 KiB
9Accepted2ms2872 KiB
10Accepted3ms2820 KiB
11Accepted2ms2944 KiB
subtask30/25
12Wrong answer126ms6168 KiB
13Wrong answer126ms6256 KiB
14Wrong answer141ms6536 KiB
15Wrong answer145ms6280 KiB
16Wrong answer160ms6220 KiB
17Wrong answer209ms7964 KiB
18Wrong answer257ms9572 KiB
19Wrong answer259ms9572 KiB
20Wrong answer256ms9640 KiB
subtask40/20
21Accepted130ms6556 KiB
22Wrong answer155ms7276 KiB
23Accepted130ms6536 KiB
24Wrong answer155ms7048 KiB
25Accepted141ms6820 KiB
26Wrong answer204ms8220 KiB
27Wrong answer252ms9564 KiB
28Wrong answer254ms9632 KiB
29Wrong answer256ms9632 KiB
30Wrong answer222ms9668 KiB
subtask50/38
31Accepted3ms3652 KiB
32Accepted3ms3716 KiB
33Accepted3ms3716 KiB
34Accepted3ms3964 KiB
35Wrong answer14ms4212 KiB
36Wrong answer146ms7000 KiB
37Wrong answer259ms10092 KiB
38Wrong answer261ms10412 KiB
39Wrong answer261ms10408 KiB
40Wrong answer261ms10716 KiB
41Wrong answer259ms10788 KiB
42Wrong answer261ms10728 KiB