#2629
h3
Tocmai ai primit cadou de ziua ta un șir de numere naturale a[1]
, a[2]
, …, a[n]
. Ca să te simți împlinit, trebuie să determini lungimea maximă a unei secvențe cu proprietatea că oricare două valori din secvență sunt distincte. Determină lungimea maximă cerută și anul viitor vei mai primi un șir!
Folclorul informatic
Problema | h3 | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.8 secunde | Limita memorie |
Total: 128 MB
/
Stivă 8 MB
|
Id soluție | #51366576 | Utilizator | |
Fișier | h3.cpp | Dimensiune | 705 B |
Data încărcării | 10 Iunie 2024, 21:43 | Scor / rezultat | Eroare de compilare |
h3.cpp:4:1: error: 'cin' does not name a type cin>>n; ^ h3.cpp:5:8: error: array bound is not an integer constant before ']' token int a[n],max,tot_max=0,ok1=0,b[n],j,m=n; ^ h3.cpp:5:33: error: array bound is not an integer constant before ']' token int a[n],max,tot_max=0,ok1=0,b[n],j,m=n; ^ h3.cpp: In function 'int ok()': h3.cpp:8:9: error: expected ';' before 'j' j=0; ^ h3.cpp:9:9: error: reference to 'max' is ambiguous max=0; ^ h3.cpp:5:10: note: candidates are: int max int a[n],max,tot_max=0,ok1=0,b[n],j,m=n; ^ 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 h3.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:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ h3.cpp:11:19: error: 'i' was not declared in this scope if(j!=i && a[i]==a[j]){ ^ h3.cpp:11:24: error: 'a' was not declared in this scope if(j!=i && a[i]==a[j]){ ^ h3.cpp:13:17: error: reference to 'max' is ambiguous max--; ^ h3.cpp:5:10: note: candidates are: int max int a[n],max,tot_max=0,ok1=0,b[n],j,m=n; ^ 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 h3.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:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ h3.cpp:15:13: error: reference to 'max' is ambiguous max++; ^ h3.cpp:5:10: note: candidates are: int max int a[n],max,tot_max=0,ok1=0,b[n],j,m=n; ^ 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 h3.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:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ h3.cpp: In function 'int main()': h3.cpp:22:14: error: 'a' was not declared in this scope cin>>a[i]; ^ h3.cpp:26:9: error: 'b' was not declared in this scope b[i]=a[i]; ^ h3.cpp:26:14: error: 'a' was not declared in this scope b[i]=a[i]; ^ h3.cpp:29:19: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] while(ok!=1){ ^ h3.cpp:30:20: warning: the address of 'int ok()' will never be NULL [-Waddress] if(ok==0)m--; ^ h3.cpp:31:21: error: reference to 'max' is ambiguous else if(max>tot_max){ ^ h3.cpp:5:10: note: candidates are: int max int a[n],max,tot_max=0,ok1=0,b[n],j,m=n; ^ 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 h3.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:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ h3.cpp:32:25: error: reference to 'max' is ambiguous tot_max=max; ^ h3.cpp:5:10: note: candidates are: int max int a[n],max,tot_max=0,ok1=0,b[n],j,m=n; ^ 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 h3.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:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema h3 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ă.