#4301
A venit ora mesei pentru Por Costel (masa dintre prânz și cină). Scormonind printr-o grădină, el descoperă un număr de N coceni de porumb și M mere. Masa lui Por Costel va consta în exact un cocean și un măr. Însă, mai nou, fanii săi l-au atenționat că trebuie să aibă grijă ce mănâncă. Fiecare cocean și fiecare măr are o valoare nutritivă. Valoarea nutritivă a mesei va fi valoarea nutritivă a coceanului ales + valoarea nutritiva a mărului ales. Dându-se valorile nutritive ale cocenilor și ale merelor, Por Costel vă întreabă dacă există o masă pe care o poate lua cu valoare nutritivă X. Pentru că Por Costel vrea sa mănânce de mai multe ori între prânz și cină, el va vă pune T întrebări de forma aceasta.
(Întrebările sunt independente între ele, a nu se considera că după o întrebare se elimină perechea cocean-mar aleasă).
Selecție pe școală, C.N. "Frații Buzești" - 2015, clasa a X-a
| Problema | gustare | Operații I/O |
gustare.in/gustare.out
|
|---|---|---|---|
| Limita timp | 0.4 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64832893 | Utilizator | |
| Fișier | gustare.cpp | Dimensiune | 568 B |
| Data încărcării | 04 Iunie 2026, 14:48 | Scor/rezultat | Eroare de compilare |
gustare.cpp: In function ‘int main()’: gustare.cpp:7:11: error: conflicting declaration ‘int N [1000]’ 7 | int N,N[1000],M,M[1000],T,T[20]; | ^ gustare.cpp:7:9: note: previous declaration as ‘int N’ 7 | int N,N[1000],M,M[1000],T,T[20]; | ^ gustare.cpp:7:21: error: conflicting declaration ‘int M [1000]’ 7 | int N,N[1000],M,M[1000],T,T[20]; | ^ gustare.cpp:7:19: note: previous declaration as ‘int M’ 7 | int N,N[1000],M,M[1000],T,T[20]; | ^ gustare.cpp:7:31: error: conflicting declaration ‘int T [20]’ 7 | int N,N[1000],M,M[1000],T,T[20]; | ^ gustare.cpp:7:29: note: previous declaration as ‘int T’ 7 | int N,N[1000],M,M[1000],T,T[20]; | ^ gustare.cpp:12:15: error: invalid types ‘int[int]’ for array subscript 12 | fin>>N[i]>>" "; | ^ gustare.cpp:14:15: error: invalid types ‘int[int]’ for array subscript 14 | fin>>M[j]>>" "; | ^ gustare.cpp:16:15: error: invalid types ‘int[int]’ for array subscript 16 | fin>>T[k]>>" "; | ^ gustare.cpp:21:10: error: invalid types ‘int[int]’ for array subscript 21 | {if(T[k]==M[J]+N[i]) | ^ gustare.cpp:21:17: error: ‘J’ was not declared in this scope 21 | {if(T[k]==M[J]+N[i]) | ^ gustare.cpp:21:21: error: invalid types ‘int[int]’ for array subscript 21 | {if(T[k]==M[J]+N[i]) | ^ gustare.cpp:24:20: error: no match for ‘operator<’ (operand types are ‘std::basic_ostream<char>’ and ‘<unresolved overloaded function type>’) 24 | fout<<"NU"<endl; | ~~~~~~~~~~^~~~~ In file included from /usr/include/c++/13/string:48, 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/ostream:40, from /usr/include/c++/13/iostream:41, from gustare.cpp:2: /usr/include/c++/13/bits/stl_iterator.h:455:5: note: candidate: ‘template<class _Iterator> bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)’ 455 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed: gustare.cpp:24:21: note: ‘std::basic_ostream<char>’ is not derived from ‘const std::reverse_iterator<_Iterator>’ 24 | fout<<"NU"<endl; | ^~~~ /usr/include/c++/13/bits/stl_iterator.h:500:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)’ 500 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed: gustare.cpp:24:21: note: ‘std::basic_ostream<char>’ is not derived from ‘const std::reverse_iterator<_Iterator>’ 24 | fout<<"NU"<endl; | ^~~~ /usr/include/c++/13/bits/stl_iterator.h:1705:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)’ 1705 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:1705:5: note: template argument deduction/substitution failed: gustare.cpp:24:21: note: ‘std::basic_ostream<char>’ is not derived from ‘const std::move_iterator<_IteratorL>’ 24 | fout<<"NU"<endl; | ^~~~ /usr/include/c++/13/bits/stl_iterator.h:1770:5: note: candidate: ‘template<class _Iterator> bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)’ 1770 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:1770:5: note: template argument deduction/substitution failed: gustare.cpp:24:21: note: ‘std::basic_ostream<char>’ is not derived from ‘const std::move_iterator<_IteratorL>’ 24 | fout<<"NU"<endl; | ^~~~ In file included from /usr/include/c++/13/bits/stl_algobase.h:64, from /usr/include/c++/13/string:51: /usr/include/c++/13/bits/stl_pair.h:835:5: note: candidate: ‘template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)’ 835 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/13/bits/stl_pair.h:835:5: note: template argument deduction/substitution failed: gustare.cpp:24:21: note: ‘std::basic_ostream<char>’ is not derived from ‘const std::pair<_T1, _T2>’ 24 | fout<<"NU"<endl; | ^~~~ In file included from /usr/include/c++/13/string:54: /usr/include/c++/13/bits/basic_string.h:3829:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)’ 3829 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:3829:5: note: template argument deduction/substitution failed: gustare.cpp:24:21: note: ‘std::basic_ostream<char>’ is not derived from ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ 24 | fout<<"NU"<endl; | ^~~~ /usr/include/c++/13/bits/basic_string.h:3843:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)’ 3843 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:3843:5: note: template argument deduction/substitution failed: gustare.cpp:24:21: note: ‘std::basic_ostream<char>’ is not derived from ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ 24 | fout<<"NU"<endl; | ^~~~ /usr/include/c++/13/bits/basic_string.h:3856:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)’ 3856 | operator<(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:3856:5: note: template argument deduction/substitution failed: gustare.cpp:24:21: note: mismatched types ‘const _CharT*’ and ‘std::basic_ostream<char>’ 24 | fout<<"NU"<endl; | ^~~~ In file included from /usr/include/c++/13/bits/ios_base.h:46: /usr/include/c++/13/system_error:324:3: note: candidate: ‘bool std::operator<(const error_code&, const error_code&)’ 324 | operator<(const error_code& __lhs, const error_code& __rhs) noexcept | ^~~~~~~~ /usr/include/c++/13/system_error:324:31: note: no known conversion for argument 1 from ‘std::basic_ostream<char>’ to ‘const std::error_code&’ 324 | operator<(const error_code& __lhs, const error_code& __rhs) noexcept | ~~~~~~~~~~~~~~~~~~^~~~~ /usr/include/c++/13/system_error:507:3: note: candidate: ‘bool std::operator<(const error_condition&, const error_condition&)’ 507 | operator<(const error_condition& __lhs, | ^~~~~~~~ /usr/include/c++/13/system_error:507:36: note: no known conversion for argument 1 from ‘std::basic_ostream<char>’ to ‘const std::error_condition&’ 507 | operator<(const error_condition& __lhs, | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~ gustare.cpp:27:2: error: expected ‘}’ at end of input 27 | } | ^ gustare.cpp:5:11: note: to match this ‘{’ 5 | int main(){ | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema gustare 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ă.