35192023-02-28 16:49:39Tina0731Szemetessorcpp11Wrong answer 0/100476ms38504 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 answer3ms1816 KiB
2Wrong answer3ms2148 KiB
subtask20/17
3Wrong answer3ms2564 KiB
4Wrong answer3ms2616 KiB
5Wrong answer3ms2712 KiB
6Wrong answer3ms2720 KiB
7Wrong answer3ms2920 KiB
8Wrong answer3ms3136 KiB
9Wrong answer3ms3200 KiB
10Wrong answer3ms3560 KiB
11Wrong answer3ms3640 KiB
subtask30/25
12Wrong answer138ms9660 KiB
13Wrong answer175ms9976 KiB
14Wrong answer202ms9856 KiB
15Wrong answer222ms10376 KiB
16Wrong answer247ms11652 KiB
17Wrong answer349ms24412 KiB
18Wrong answer449ms38340 KiB
19Wrong answer476ms38504 KiB
20Wrong answer474ms38500 KiB
subtask40/20
21Wrong answer180ms11536 KiB
22Wrong answer238ms16576 KiB
23Wrong answer184ms12128 KiB
24Wrong answer223ms14020 KiB
25Wrong answer192ms11956 KiB
26Wrong answer316ms22412 KiB
27Wrong answer391ms29140 KiB
28Wrong answer400ms29500 KiB
29Wrong answer393ms28712 KiB
30Wrong answer356ms27976 KiB
subtask50/38
31Wrong answer3ms4956 KiB
32Wrong answer3ms5076 KiB
33Wrong answer3ms4988 KiB
34Wrong answer3ms4852 KiB
35Wrong answer17ms5192 KiB
36Wrong answer197ms10968 KiB
37Wrong answer402ms20448 KiB
38Wrong answer400ms19092 KiB
39Wrong answer405ms22428 KiB
40Wrong answer412ms26860 KiB
41Wrong answer419ms29640 KiB
42Wrong answer419ms28084 KiB