#2179
Max3
Fie n
un număr natural nenul şi un şir de n
numere naturale nenule, fiecare număr din şir având cel mult 3
cifre. Şirul dat se „maximizează”
prin aplicarea următoarelor transformări:
ONI GIM 2010
Problema | Max3 | Operații I/O |
max3.in /max3.out
|
---|---|---|---|
Limita timp | 1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #48835798 | Utilizator | |
Fișier | max3.cpp | Dimensiune | 648 B |
Data încărcării | 07 Februarie 2024, 08:31 | Scor / rezultat | Eroare de compilare |
max3.cpp: In function 'int t1(std::vector<int>, int)': max3.cpp:24:19: error: no matching function for call to 'max(<unresolved overloaded function type>, int&)' maxi=max(max,m); ^ max3.cpp:24:19: note: candidates are: In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from max3.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = int] max(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const int&' /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template argument deduction/substitution failed: max3.cpp:24:19: note: candidate expects 3 arguments, 2 provided maxi=max(max,m); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from max3.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:4231:5: note: template<class _Tp> _Tp std::max(std::initializer_list<_Tp>) max(initializer_list<_Tp> __l) ^ /usr/include/c++/4.8/bits/stl_algo.h:4231:5: note: template argument deduction/substitution failed: max3.cpp:24:19: note: candidate expects 1 argument, 2 provided maxi=max(max,m); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from max3.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:4236:5: note: template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare) max(initializer_list<_Tp> __l, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algo.h:4236:5: note: template argument deduction/substitution failed: max3.cpp:24:19: note: couldn't deduce template parameter '_Tp' maxi=max(max,m); ^ max3.cpp:26:16: error: cannot resolve overloaded function 'max' based on conversion to type 'int' return max; ^ max3.cpp: In function 'int main()': max3.cpp:38:15: warning: left operand of comma operator has no effect [-Wunused-value] cout<<(nr,n) ^ max3.cpp:40:1: error: expected ';' before '}' token } ^ max3.cpp: In function 'int t1(std::vector<int>, int)': max3.cpp:27:1: warning: control reaches end of non-void function [-Wreturn-type] } ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Max3 face parte din prima categorie. 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ă.