106912024-04-09 15:33:25AncsaSzemetessorcpp17Wrong answer 17/100509ms125132 KiB
#include <bits/stdc++.h>

using namespace std;

/*
2 3
5 7
0 4
1 1
1 7

kimenet: 7
*/

/*
5 12
66 73 68 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> 168
*/

void mapkiir(map<int,int> a)
{
    cout<<"*******\n";
    for(pair<int,int> x : a)
        cout<<x.first<<"\t"<<x.second<<endl;

    cout <<"+++++++++\n";
}


int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> kapacitas(n);
    for(int i=0;i<n;i++)
        cin>>kapacitas.at(i);


    pair <int, int> nap;
    map <int,int> kukak;

    for(int i=0;i<n;i++)
    {
        kukak[i]=kapacitas.at(i);
    }


    int fizetni=0;
    for(int i=0;i<k;i++)
    {
        cin>>nap.first>>nap.second;
        kukak[nap.first]-=nap.second;

        if(kukak[nap.first]<0)
        {
            kukak[nap.first]+=nap.second;
            int fizetmost=kukak[nap.first];
            //cout<<i<<" nap"<<nap.first<<" sorszamu kukaert fizet "<<fizetmost<<" penzt. "<<endl;

            kukak[nap.first]=kapacitas.at(nap.first)-nap.second;
            fizetni+=fizetmost;
        }
        //mapkiir(kukak);
    }

    for(pair<int,int> x : kukak)
    {
        if (x.second!=kapacitas.at(x.first))
        {
            fizetni+=x.second;
        }
    }
    cout<<fizetni;
    //cout << "Hello world!" << endl;*/
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1812 KiB
2Accepted3ms2052 KiB
subtask217/17
3Accepted3ms2256 KiB
4Accepted3ms2504 KiB
5Accepted3ms2756 KiB
6Accepted3ms2964 KiB
7Accepted3ms3020 KiB
8Accepted3ms3080 KiB
9Accepted3ms3092 KiB
10Accepted3ms3220 KiB
11Accepted3ms3184 KiB
subtask30/25
12Wrong answer136ms5244 KiB
13Wrong answer173ms7420 KiB
14Wrong answer202ms10136 KiB
15Wrong answer218ms12884 KiB
16Wrong answer254ms16508 KiB
17Wrong answer370ms29756 KiB
18Wrong answer439ms45412 KiB
19Wrong answer439ms50388 KiB
20Wrong answer439ms55472 KiB
subtask40/20
21Accepted186ms38632 KiB
22Wrong answer244ms45248 KiB
23Accepted186ms43572 KiB
24Wrong answer229ms47848 KiB
25Accepted194ms48668 KiB
26Wrong answer331ms61532 KiB
27Wrong answer432ms75888 KiB
28Wrong answer442ms81568 KiB
29Wrong answer442ms86624 KiB
30Wrong answer405ms91152 KiB
subtask50/38
31Accepted3ms70796 KiB
32Accepted3ms70804 KiB
33Accepted3ms70916 KiB
34Accepted3ms71060 KiB
35Wrong answer20ms72200 KiB
36Wrong answer202ms74024 KiB
37Wrong answer509ms99248 KiB
38Wrong answer508ms104404 KiB
39Wrong answer501ms109464 KiB
40Wrong answer481ms114628 KiB
41Wrong answer472ms119836 KiB
42Wrong answer477ms125132 KiB