#2273
ssplit
Se consideră un șir a[1]
, a[2]
, …, a[n]
de numere naturale nenule. Pentru doi indici 1 ≤ i < j < n
, notăm cu X = a[1] + a[2] + ... + a[i]
, Y = a[i+1] + a[i+2] + ... + a[j]
și Z = a[j+1] + a[j+2] + ... + a[n]
. Să se determine doi indici i
și j
astfel încât diferența max(X, Y, Z) - min(X, Y, Z)
să fie minimă.
Problema | ssplit | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.2 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #54280578 | Utilizator | |
Fișier | ssplit.cpp | Dimensiune | 1.21 KB |
Data încărcării | 24 Noiembrie 2024, 17:24 | Scor / rezultat | Eroare de compilare |
ssplit.cpp: In function 'int main()': ssplit.cpp:31:40: error: no matching function for call to 'max(<brace-enclosed initializer list>)' int diff = max({t1, t2, t3}) - min({t1, t2, t3}); ^ ssplit.cpp:31:40: 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 ssplit.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: ssplit.cpp:31:40: note: candidate expects 2 arguments, 1 provided int diff = max({t1, t2, t3}) - min({t1, t2, t3}); ^ 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 ssplit.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: ssplit.cpp:31:40: note: candidate expects 3 arguments, 1 provided int diff = max({t1, t2, t3}) - min({t1, t2, t3}); ^ ssplit.cpp:31:60: error: no matching function for call to 'min(<brace-enclosed initializer list>)' int diff = max({t1, t2, t3}) - min({t1, t2, t3}); ^ ssplit.cpp:31:60: 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 ssplit.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:193:5: note: template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&) min(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/4.8/bits/stl_algobase.h:193:5: note: template argument deduction/substitution failed: ssplit.cpp:31:60: note: candidate expects 2 arguments, 1 provided int diff = max({t1, t2, t3}) - min({t1, t2, t3}); ^ 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 ssplit.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:239:5: note: template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare) min(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algobase.h:239:5: note: template argument deduction/substitution failed: ssplit.cpp:31:60: note: candidate expects 3 arguments, 1 provided int diff = max({t1, t2, t3}) - min({t1, t2, t3}); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema ssplit 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ă.