35222023-02-28 16:53:13Tina0731Szemetessorcpp11Wrong answer 17/100430ms38320 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(long long int i=0;i<n;i++)
        cin>>kapac.at(i);

     for(long long 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<long long int, long long 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< long long int, long long int> par:tarolo)
    {
        if(par.second>0)
            moneymoney+=kapac.at(par.first)-tarolo.at(par.first);
    }

    cout<<moneymoney;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1812 KiB
2Accepted3ms2056 KiB
subtask217/17
3Accepted3ms2264 KiB
4Accepted3ms2512 KiB
5Accepted3ms2764 KiB
6Accepted3ms2960 KiB
7Accepted3ms3476 KiB
8Accepted3ms3436 KiB
9Accepted3ms3364 KiB
10Accepted3ms3612 KiB
11Accepted3ms3588 KiB
subtask30/25
12Wrong answer143ms9616 KiB
13Wrong answer175ms9880 KiB
14Wrong answer201ms9976 KiB
15Wrong answer221ms10600 KiB
16Wrong answer245ms11608 KiB
17Wrong answer337ms24180 KiB
18Wrong answer430ms38164 KiB
19Wrong answer428ms38320 KiB
20Wrong answer428ms38192 KiB
subtask40/20
21Accepted180ms11160 KiB
22Wrong answer232ms16008 KiB
23Accepted187ms11336 KiB
24Wrong answer221ms13376 KiB
25Accepted192ms11292 KiB
26Wrong answer308ms21696 KiB
27Wrong answer393ms28192 KiB
28Wrong answer379ms28584 KiB
29Wrong answer372ms28060 KiB
30Wrong answer333ms27456 KiB
subtask50/38
31Accepted3ms4320 KiB
32Accepted3ms4308 KiB
33Accepted3ms4436 KiB
34Accepted3ms4532 KiB
35Wrong answer17ms4872 KiB
36Wrong answer195ms10548 KiB
37Wrong answer381ms19916 KiB
38Wrong answer372ms18484 KiB
39Wrong answer379ms21732 KiB
40Wrong answer388ms26420 KiB
41Wrong answer393ms29152 KiB
42Wrong answer389ms27592 KiB