#3579
S_maxim
Fie un vector cu n elemente numere naturale. Determinați suma maximă care se poate obține prin adunarea valorilor care nu se află pe poziții consecutive în vector.
Problema | S_maxim | Operații I/O |
![]() smax.in /smax.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 16 MB
|
Id soluție | #58584942 | Utilizator | |
Fișier | s_maxim.cpp | Dimensiune | 943 B |
Data încărcării | 24 Iunie 2025, 18:34 | Scor / rezultat | Eroare de compilare |
s_maxim.cpp: In function 'int main()': s_maxim.cpp:35:54: error: no matching function for call to 'max(<brace-enclosed initializer list>)' dp[3] = max({1LL * v[3], v[1] + v[3], v[1], v[2]}); ^ s_maxim.cpp:35:54: 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/ostream:38, from /usr/include/c++/4.8/iostream:39, from s_maxim.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template argument deduction/substitution failed: s_maxim.cpp:35:54: note: candidate expects 2 arguments, 1 provided dp[3] = max({1LL * v[3], v[1] + v[3], v[1], v[2]}); ^ 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/ostream:38, from /usr/include/c++/4.8/iostream:39, from s_maxim.cpp:1: /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: s_maxim.cpp:35:54: note: candidate expects 3 arguments, 1 provided dp[3] = max({1LL * v[3], v[1] + v[3], v[1], v[2]}); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from s_maxim.cpp:3: /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: s_maxim.cpp:35:54: note: deduced conflicting types for parameter '_Tp' ('long long int' and 'int') dp[3] = max({1LL * v[3], v[1] + v[3], v[1], v[2]}); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from s_maxim.cpp:3: /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: s_maxim.cpp:35:54: note: deduced conflicting types for parameter '_Tp' ('long long int' and 'int') dp[3] = max({1LL * v[3], v[1] + v[3], v[1], v[2]}); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema S_maxim 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ă.