108542024-04-16 17:18:10ERDROMSzemetessorcpp17Wrong answer 17/100391ms25784 KiB
#include<bits/stdc++.h>
#include<fstream>
#include<map>

using namespace std;

int main()
{
   long long int n, k;
   cin>>n>>k;
   long long int kapacitas[n];
   for (int i=0; i<n; i++)
   {
       cin>>kapacitas[i];
   }

   map <int, int> kuka;
   int fizetni=0;
   for (int i=0; i<k; i++)
   {
       int sorszam, mennyi;
       cin>>sorszam>>mennyi;
       kuka[sorszam]+=mennyi;
       if (kuka[sorszam]>kapacitas[sorszam])
       {
          kuka[sorszam]-=mennyi;
          fizetni+=(kapacitas[sorszam]-kuka[sorszam]);
          kuka[sorszam]=mennyi;
       }

   }
   for (pair<int, int> x:kuka)
   {
       if (x.second>0)
        fizetni+=kapacitas[x.first]-x.second;
   }

   cout<<fizetni;

















   /*
    map <string, int> a;
    ifstream be ("gyumi.txt");
    if(! be.is_open())
    {
        cout<<"Hiba";
        return 0;
    }

    while (!be.eof())
    {
        string gy;
        int szam;
        be>>gy;
        be>>szam;
        a[gy]+=szam;
    }

    for (pair<string, int> x : a)
    {
        cout<<x.first<<"\t "<<x.second<<endl;
    }
    */
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1684 KiB
2Accepted3ms1852 KiB
subtask217/17
3Accepted3ms2060 KiB
4Accepted3ms2300 KiB
5Accepted3ms2480 KiB
6Accepted3ms2728 KiB
7Accepted3ms2940 KiB
8Accepted3ms3192 KiB
9Accepted3ms3220 KiB
10Accepted3ms3300 KiB
11Accepted3ms3300 KiB
subtask30/25
12Wrong answer135ms3544 KiB
13Wrong answer171ms3420 KiB
14Wrong answer199ms3536 KiB
15Wrong answer218ms3812 KiB
16Wrong answer241ms4660 KiB
17Wrong answer324ms14584 KiB
18Wrong answer391ms25784 KiB
19Wrong answer377ms25588 KiB
20Wrong answer386ms25432 KiB
subtask40/20
21Accepted175ms4452 KiB
22Wrong answer224ms8308 KiB
23Accepted179ms4664 KiB
24Wrong answer212ms6348 KiB
25Accepted186ms4720 KiB
26Wrong answer287ms12820 KiB
27Wrong answer347ms18140 KiB
28Wrong answer349ms18368 KiB
29Wrong answer347ms18160 KiB
30Wrong answer314ms17924 KiB
subtask50/38
31Accepted3ms4396 KiB
32Accepted3ms4376 KiB
33Accepted3ms4500 KiB
34Accepted3ms4500 KiB
35Wrong answer17ms4816 KiB
36Wrong answer193ms4508 KiB
37Wrong answer363ms12272 KiB
38Wrong answer361ms11200 KiB
39Wrong answer365ms14016 KiB
40Wrong answer370ms17416 KiB
41Wrong answer372ms19616 KiB
42Wrong answer370ms18508 KiB