#3592
DifferenceK
Se dă un vector cu n
elemente care aparțin intervalului [1, p]
, iar modulul diferenței dintre oricare 2
valori consecutive este maxim k
. Fane a șters câteva dintre numere, scriind in locul lor numărul 0
. Aflați numărul de modalități de a completa numerele șterse de Fane, astfel încât vectorul să respecte cele 2
condiții.
Problema | DifferenceK | Operații I/O |
![]() |
---|---|---|---|
Limita timp | 0.01 secunde | Limita memorie |
Total: 0.1 MB
/
Stivă 0.1 MB
|
Id soluție | #44364272 | Utilizator | |
Fișier | differencek.cpp | Dimensiune | 894 B |
Data încărcării | 08 August 2023, 09:09 | Scor / rezultat | Eroare de compilare |
differencek.cpp: In function 'int main()': differencek.cpp:22:23: error: no matching function for call to 'max(long long int, int)' {a2[max(j-k,1)]=a2[max(j-k,1)]+a1[j]; ^ differencek.cpp:22:23: 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 differencek.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: differencek.cpp:22:23: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') {a2[max(j-k,1)]=a2[max(j-k,1)]+a1[j]; ^ 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 differencek.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: differencek.cpp:22:23: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') {a2[max(j-k,1)]=a2[max(j-k,1)]+a1[j]; ^ differencek.cpp:22:38: error: no matching function for call to 'max(long long int, int)' {a2[max(j-k,1)]=a2[max(j-k,1)]+a1[j]; ^ differencek.cpp:22:38: 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 differencek.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: differencek.cpp:22:38: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') {a2[max(j-k,1)]=a2[max(j-k,1)]+a1[j]; ^ 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 differencek.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: differencek.cpp:22:38: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') {a2[max(j-k,1)]=a2[max(j-k,1)]+a1[j]; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema DifferenceK 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ă.