108462024-04-16 16:33:36turitamasSzemetessorcpp17Wrong answer 0/100244ms10224 KiB
#include <iostream>

using namespace std;

int main()
{
    int n, k;

    cin>>n>>k;

    int c[n]={0};
    int m[n]={0};

    int t[k][2];

    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
        {
            a+=c[t[i][0]]-m[t[i][0]];
            m[t[i][0]]=0;
            m[t[i][0]]+=t[i][1];
        }
    }
    for(int i=0; i<n; i++)
    {
        a+=c[i]-m[i];
    }

    cout<<a;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1912 KiB
2Accepted3ms2216 KiB
subtask20/17
3Accepted3ms2356 KiB
4Accepted3ms2496 KiB
5Accepted3ms2636 KiB
6Wrong answer3ms2852 KiB
7Accepted3ms2968 KiB
8Accepted3ms2964 KiB
9Wrong answer3ms3096 KiB
10Accepted3ms3088 KiB
11Wrong answer3ms3056 KiB
subtask30/25
12Wrong answer126ms6280 KiB
13Wrong answer119ms6376 KiB
14Wrong answer133ms6336 KiB
15Wrong answer137ms6344 KiB
16Wrong answer149ms6328 KiB
17Wrong answer194ms7816 KiB
18Wrong answer240ms9412 KiB
19Wrong answer240ms9668 KiB
20Wrong answer240ms9624 KiB
subtask40/20
21Wrong answer123ms6924 KiB
22Wrong answer144ms7632 KiB
23Wrong answer126ms6816 KiB
24Wrong answer145ms7072 KiB
25Wrong answer133ms6816 KiB
26Wrong answer193ms8292 KiB
27Wrong answer234ms9628 KiB
28Wrong answer236ms9808 KiB
29Wrong answer237ms9800 KiB
30Wrong answer208ms9832 KiB
subtask50/38
31Accepted3ms3644 KiB
32Accepted3ms3644 KiB
33Wrong answer3ms3644 KiB
34Wrong answer3ms3656 KiB
35Wrong answer14ms3940 KiB
36Wrong answer137ms6844 KiB
37Wrong answer241ms9856 KiB
38Wrong answer241ms10000 KiB
39Wrong answer241ms10160 KiB
40Wrong answer240ms10224 KiB
41Wrong answer244ms10116 KiB
42Wrong answer243ms10064 KiB