#4447
Înaintea vacanței de Paște, la școală, s-au primit cadouri pentru elevii din clasa a V-a. Sunt N cutii cu bomboane și se cunoaște numărul de bomboane din fiecare cutie. Numărul de cutii de bomboane primite de fiecare copil trebuie să fie același. Acest număr trebuie să fie mai mare sau egal cu 2. Alegerea acestei cutii trebuie făcută astfel încât numărul total de bomboane care se împart să fie cât mai mare.
1) Care este numărul maxim de copii care vor primi cadouri?
2) Care este numărul maxim posibil de bomboane pe care le poate primi un copil în condițiile descrise mai sus?
Pentru ambele cerințe trebuie determinat și numărul de bomboane din cutia care eventual se păstrează.
ONI 2023 clasa a V-a
| Problema | cadouri1 | Operații I/O |
cadouri.in/cadouri.out
|
|---|---|---|---|
| Limita timp | 0.2 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64103917 | Utilizator | |
| Fișier | cadouri1.cpp | Dimensiune | 1.48 KB |
| Data încărcării | 17 Aprilie 2026, 09:27 | Scor/rezultat | Eroare de compilare |
cadouri1.cpp: In function ‘int main()’: cadouri1.cpp:14:27: error: no matching function for call to ‘min(int&, long long int&)’ 14 | mini = min(mini, u[i]); | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/13/string:51, from /usr/include/c++/13/bits/locale_classes.h:40, from /usr/include/c++/13/bits/ios_base.h:41, from /usr/include/c++/13/ios:44, from /usr/include/c++/13/istream:40, from /usr/include/c++/13/fstream:40, from cadouri1.cpp:1: /usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)’ 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: cadouri1.cpp:14:27: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’) 14 | mini = min(mini, u[i]); | ~~~^~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’ 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:281:5: note: template argument deduction/substitution failed: cadouri1.cpp:14:27: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’) 14 | mini = min(mini, u[i]); | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:61, from cadouri1.cpp:2: /usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: ‘template<class _Tp> _Tp std::min(initializer_list<_Tp>)’ 5775 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5775:5: note: template argument deduction/substitution failed: cadouri1.cpp:14:27: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 14 | mini = min(mini, u[i]); | ~~~^~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: ‘template<class _Tp, class _Compare> _Tp std::min(initializer_list<_Tp>, _Compare)’ 5785 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5785:5: note: template argument deduction/substitution failed: cadouri1.cpp:14:27: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 14 | mini = min(mini, u[i]); | ~~~^~~~~~~~~~~~ cadouri1.cpp:30:43: error: no matching function for call to ‘max(int&, long long int)’ 30 | maxi = max(maxi, u[i] + u[i + 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: cadouri1.cpp:30:43: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’) 30 | maxi = max(maxi, u[i] + u[i + 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: template argument deduction/substitution failed: cadouri1.cpp:30:43: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’) 30 | maxi = max(maxi, u[i] + u[i + 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> _Tp std::max(initializer_list<_Tp>)’ 5795 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5795:5: note: template argument deduction/substitution failed: cadouri1.cpp:30:43: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 30 | maxi = max(maxi, u[i] + u[i + 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> _Tp std::max(initializer_list<_Tp>, _Compare)’ 5805 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: template argument deduction/substitution failed: cadouri1.cpp:30:43: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 30 | maxi = max(maxi, u[i] + u[i + 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ cadouri1.cpp:43:51: error: no matching function for call to ‘max(int&, long long int)’ 43 | maxi = max(maxi, u[i - 1] + u[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: cadouri1.cpp:43:51: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’) 43 | maxi = max(maxi, u[i - 1] + u[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: template argument deduction/substitution failed: cadouri1.cpp:43:51: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’) 43 | maxi = max(maxi, u[i - 1] + u[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> _Tp std::max(initializer_list<_Tp>)’ 5795 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5795:5: note: template argument deduction/substitution failed: cadouri1.cpp:43:51: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 43 | maxi = max(maxi, u[i - 1] + u[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> _Tp std::max(initializer_list<_Tp>, _Compare)’ 5805 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: template argument deduction/substitution failed: cadouri1.cpp:43:51: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 43 | maxi = max(maxi, u[i - 1] + u[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ cadouri1.cpp:55:51: error: no matching function for call to ‘max(int&, long long int)’ 55 | maxi = max(maxi, u[i] + u[i + 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: cadouri1.cpp:55:51: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’) 55 | maxi = max(maxi, u[i] + u[i + 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: template argument deduction/substitution failed: cadouri1.cpp:55:51: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’) 55 | maxi = max(maxi, u[i] + u[i + 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> _Tp std::max(initializer_list<_Tp>)’ 5795 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5795:5: note: template argument deduction/substitution failed: cadouri1.cpp:55:51: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 55 | maxi = max(maxi, u[i] + u[i + 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> _Tp std::max(initializer_list<_Tp>, _Compare)’ 5805 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: template argument deduction/substitution failed: cadouri1.cpp:55:51: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 55 | maxi = max(maxi, u[i] + u[i + 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ cadouri1.cpp:69:51: error: no matching function for call to ‘max(int&, long long int)’ 69 | maxi = max(maxi, u[v[i] - 1] + u[v[i] + 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: cadouri1.cpp:69:51: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’) 69 | maxi = max(maxi, u[v[i] - 1] + u[v[i] + 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: template argument deduction/substitution failed: cadouri1.cpp:69:51: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’) 69 | maxi = max(maxi, u[v[i] - 1] + u[v[i] + 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> _Tp std::max(initializer_list<_Tp>)’ 5795 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5795:5: note: template argument deduction/substitution failed: cadouri1.cpp:69:51: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 69 | maxi = max(maxi, u[v[i] - 1] + u[v[i] + 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> _Tp std::max(initializer_list<_Tp>, _Compare)’ 5805 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: template argument deduction/substitution failed: cadouri1.cpp:69:51: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 69 | maxi = max(maxi, u[v[i] - 1] + u[v[i] + 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cadouri1.cpp:9:25: warning: unused variable ‘j’ [-Wunused-variable] 9 | int cerinta, i, j, mini; | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema cadouri1 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ă.