35202023-02-28 16:50:25Tina0731Szemetessorcpp11Wrong answer 0/100437ms38244 KiB
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

/*
5 12
33 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
*/

int main()
{
    long long int n, k;
    cin>>n>>k;
    vector<pair<long long int, long long int>> szemet(k);
     vector<long long int> kapac(n);

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

     for(int i=0;i<k;i++)
        cin>>szemet.at(i).first>>szemet.at(i).second;

     /*for(int x:kapac)
        cout<<x<<" ";*/

     cout<<endl;

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


    map<long long int, long long int> tarolo;
        //cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"<<endl;
        int moneymoney=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;
            moneymoney+=kapac.at(par.first)-tarolo.at(par.first);
            tarolo.at(par.first)=par.second;
        }

    }

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

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

    cout<<moneymoney;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1812 KiB
2Wrong answer3ms2056 KiB
subtask20/17
3Wrong answer3ms2300 KiB
4Wrong answer2ms2352 KiB
5Wrong answer3ms2492 KiB
6Wrong answer3ms2816 KiB
7Wrong answer3ms2916 KiB
8Wrong answer3ms2996 KiB
9Wrong answer3ms3124 KiB
10Wrong answer3ms3184 KiB
11Wrong answer3ms3256 KiB
subtask30/25
12Wrong answer136ms9540 KiB
13Wrong answer175ms9832 KiB
14Wrong answer202ms10048 KiB
15Wrong answer221ms10532 KiB
16Wrong answer246ms11816 KiB
17Wrong answer335ms24304 KiB
18Wrong answer437ms38244 KiB
19Wrong answer433ms38208 KiB
20Wrong answer423ms38224 KiB
subtask40/20
21Wrong answer180ms11224 KiB
22Wrong answer231ms16264 KiB
23Wrong answer186ms11716 KiB
24Wrong answer219ms13648 KiB
25Wrong answer190ms11572 KiB
26Wrong answer300ms21972 KiB
27Wrong answer367ms28464 KiB
28Wrong answer393ms28860 KiB
29Wrong answer391ms28232 KiB
30Wrong answer351ms27448 KiB
subtask50/38
31Wrong answer3ms4368 KiB
32Wrong answer3ms4492 KiB
33Wrong answer3ms4496 KiB
34Wrong answer3ms4384 KiB
35Wrong answer17ms4724 KiB
36Wrong answer196ms10400 KiB
37Wrong answer384ms19932 KiB
38Wrong answer377ms18480 KiB
39Wrong answer389ms21856 KiB
40Wrong answer388ms26472 KiB
41Wrong answer395ms29196 KiB
42Wrong answer388ms27708 KiB