#3798
NrMinMaxAp
C++
Scrieți funcția care are antetul:
int NrMinMaxAp(vector<int> &a)
Funcția va returna numărul care apare de cele mai multe ori în a
. Dacă există mai multe numere care apar de număr maxim de ori, se va returna minimul dintre ele.
Problema | NrMinMaxAp | Operații I/O |
nrminmaxap.in /nrminmaxap.out
|
---|---|---|---|
Limita timp | 0.3 secunde | Limita memorie |
Total: 256 MB
/
Stivă 128 MB
|
Id soluție | #49407221 | Utilizator | |
Fișier | nrminmaxap.cpp | Dimensiune | 319 B |
Data încărcării | 29 Februarie 2024, 11:11 | Scor / rezultat | Eroare de compilare |
nrminmaxap.cpp: In function 'int NrMinMaxAp(std::vector<int>&)': nrminmaxap.cpp:10:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i=0; i<a.size(); i++) ^ nrminmaxap.cpp:14:20: error: no match for 'operator[]' (operand types are 'std::unordered_map<int, int>' and 'std::pair<const int, int>') if(aparitii[i]>maxim) ^ nrminmaxap.cpp:14:20: note: candidates are: In file included from /usr/include/c++/4.8/unordered_map:48:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:115, from nrminmaxap.cpp:1: /usr/include/c++/4.8/bits/unordered_map.h:595:7: note: std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = int] operator[](const key_type& __k) ^ /usr/include/c++/4.8/bits/unordered_map.h:595:7: note: no known conversion for argument 1 from 'std::pair<const int, int>' to 'const key_type& {aka const int&}' /usr/include/c++/4.8/bits/unordered_map.h:599:7: note: std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type&&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = int] operator[](key_type&& __k) ^ /usr/include/c++/4.8/bits/unordered_map.h:599:7: note: no known conversion for argument 1 from 'std::pair<const int, int>' to 'std::unordered_map<int, int>::key_type&& {aka int&&}' nrminmaxap.cpp:16:24: error: no match for 'operator[]' (operand types are 'std::unordered_map<int, int>' and 'std::pair<const int, int>') maxim=aparitii[i]; ^ nrminmaxap.cpp:16:24: note: candidates are: In file included from /usr/include/c++/4.8/unordered_map:48:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:115, from nrminmaxap.cpp:1: /usr/include/c++/4.8/bits/unordered_map.h:595:7: note: std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = int] operator[](const key_type& __k) ^ /usr/include/c++/4.8/bits/unordered_map.h:595:7: note: no known conversion for argument 1 from 'std::pair<const int, int>' to 'const key_type& {aka const int&}' /usr/include/c++/4.8/bits/unordered_map.h:599:7: note: std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type&&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = int] operator[](key_type&& __k) ^ /usr/include/c++/4.8/bits/unordered_map.h:599:7: note: no known conversion for argument 1 from 'std::pair<const int, int>' to 'std::unordered_map<int, int>::key_type&& {aka int&&}' nrminmaxap.cpp:17:13: error: cannot convert 'std::pair<const int, int>' to 'int' in assignment rez=i; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema NrMinMaxAp face parte din a doua categorie. Pentru aceste probleme se folosește un program suport, furnizat de propunătorul problemei. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.