#282
Se dă un şir cu n elemente, numere reale, numerotate de la 1 la n. Determinaţi numărul de ordine al primei şi al ultimei apariţii a valorii maxime din şir.
| Problema | PozMax | Operații I/O |
pozmax.in/pozmax.out
|
|---|---|---|---|
| Limita timp | 0.2 secunde | Limita memorie |
Total: 32 MB
/
Stivă 8 MB
|
| Id soluție | #64488976 | Utilizator | |
| Fișier | pozmax.cpp | Dimensiune | 414 B |
| Data încărcării | 10 Mai 2026, 21:36 | Scor/rezultat | Eroare de compilare |
pozmax.cpp: In function ‘int main()’: pozmax.cpp:8:12: error: reference to ‘max’ is ambiguous 8 | cin >> max; | ^~~ 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/ostream:40, from /usr/include/c++/13/iostream:41, from pozmax.cpp:1: /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidates are: ‘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:257:5: note: ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ pozmax.cpp:3:13: note: ‘int max’ 3 | int n,x,p,u,max,i; | ^~~ pozmax.cpp:17:17: error: ‘maxim’ was not declared in this scope; did you mean ‘max’? 17 | if (x > maxim) { | ^~~~~ | max pozmax.cpp:19:13: error: reference to ‘max’ is ambiguous 19 | max = x; | ^~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidates are: ‘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:257:5: note: ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ pozmax.cpp:3:13: note: ‘int max’ 3 | int n,x,p,u,max,i; | ^~~ pozmax.cpp:23:21: error: reference to ‘max’ is ambiguous 23 | else if (x==max) { | ^~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidates are: ‘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:257:5: note: ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ pozmax.cpp:3:13: note: ‘int max’ 3 | int n,x,p,u,max,i; | ^~~ pozmax.cpp:25:13: error: ‘ultima’ was not declared in this scope 25 | ultima=i; | ^~~~~~ pozmax.cpp:29:12: error: ‘prima’ was not declared in this scope 29 | cout <<prima<< " " <<ultima; | ^~~~~ pozmax.cpp:29:26: error: ‘ultima’ was not declared in this scope 29 | cout <<prima<< " " <<ultima; | ^~~~~~ pozmax.cpp:32:2: error: expected ‘}’ at end of input 32 | } | ^ pozmax.cpp:4:12: note: to match this ‘{’ 4 | int main() { | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema PozMax 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ă.