35242023-02-28 17:14:46AncsaSzemetessorcpp11Wrong answer 0/100833ms27648 KiB
#include <bits/stdc++.h>

/*
5 12
66 73 69 79 78
2 50
3 69
0 1
0 12
2 20
0 23
1 44
1 30
4 12
4 3
4 63
0 10

kimenet:
*/



using namespace std;

int main()
{
    int kszam, napsz;
    cin>>kszam>>napsz;
    vector<pair<int, int>> szemet(napsz);
    vector<int> kapac(kszam);

    for(int i=0;i<kszam;i++)
        cin>>kapac.at(i);

    for(int i=0;i<napsz;i++)
    {
        cin>>szemet.at(i).first>>szemet.at(i).second;
    }
/*
    for(int x:kapac)
        cout<<x<<" ";

    cout<<endl;
*/
    for(pair<int,int> par: szemet)
        cout<<par.first<<" "<<par.second<<endl;

    map<int,int> tarolo;

    long long int fizetni=0;
    for(pair<int,int> par: szemet)
    {
        tarolo[par.first]+=par.second;
        if (tarolo[par.first]>kapac.at(par.first))
        {
           tarolo[par.first]-=par.second;
           fizetni+=kapac.at(par.first)-tarolo.at(par.first);
           tarolo.at(par.first)=par.second;
        }

    }
    /*
    cout<<"A map tartalma: \n\n";
    for(pair<int,int> elem:tarolo)
        cout<<elem.first<<" "<<elem.second<<endl;
*/

    for(pair<int,int> elem:tarolo)
    {
        if(elem.second>0)
            fizetni+=kapac.at(elem.first)-tarolo.at(elem.first);
    }

    cout<<fizetni;


    //cout << "Hello world!" << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1680 KiB
2Wrong answer3ms1860 KiB
subtask20/17
3Wrong answer3ms2236 KiB
4Wrong answer3ms2452 KiB
5Wrong answer3ms2632 KiB
6Wrong answer3ms2848 KiB
7Wrong answer3ms3056 KiB
8Wrong answer3ms3296 KiB
9Wrong answer3ms3268 KiB
10Wrong answer3ms3412 KiB
11Wrong answer3ms3516 KiB
subtask30/25
12Wrong answer605ms6556 KiB
13Wrong answer584ms7032 KiB
14Wrong answer630ms6796 KiB
15Wrong answer561ms7200 KiB
16Wrong answer675ms7772 KiB
17Wrong answer773ms16964 KiB
18Wrong answer833ms27432 KiB
19Wrong answer750ms27632 KiB
20Wrong answer791ms27648 KiB
subtask40/20
21Wrong answer430ms8104 KiB
22Wrong answer651ms11316 KiB
23Wrong answer584ms8084 KiB
24Wrong answer587ms9664 KiB
25Wrong answer556ms8132 KiB
26Wrong answer721ms15428 KiB
27Wrong answer625ms20012 KiB
28Wrong answer591ms20676 KiB
29Wrong answer717ms20004 KiB
30Wrong answer654ms19604 KiB
subtask50/38
31Wrong answer3ms4652 KiB
32Wrong answer3ms4740 KiB
33Wrong answer3ms4572 KiB
34Wrong answer4ms4684 KiB
35Wrong answer41ms4952 KiB
36Wrong answer460ms7680 KiB
37Wrong answer614ms14148 KiB
38Wrong answer578ms13208 KiB
39Wrong answer788ms15848 KiB
40Wrong answer797ms18984 KiB
41Wrong answer614ms21168 KiB
42Wrong answer750ms20092 KiB