#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 | #64511108 | Utilizator | |
| Fișier | pozmax.cpp | Dimensiune | 429 B |
| Data încărcării | 11 Mai 2026, 22:08 | Scor/rezultat | Eroare de compilare |
pozmax.cpp:3:13: error: variable ‘std::ifstream fin’ has initializer but incomplete type 3 | ifstream fin("pozmax.in"); | ^ pozmax.cpp:4:14: error: variable ‘std::ofstream fout’ has initializer but incomplete type 4 | ofstream fout("pozmax.out"); | ^ pozmax.cpp: In function ‘int main()’: pozmax.cpp:13:16: error: reference to ‘max’ is ambiguous 13 | if(tmp>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:5:18: note: ‘int max’ 5 | int n, p=0, u=0, max=0, i; | ^~~ pozmax.cpp:16:13: error: reference to ‘max’ is ambiguous 16 | max=tmp; | ^~~ /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:5:18: note: ‘int max’ 5 | int n, p=0, u=0, max=0, i; | ^~~ pozmax.cpp:18:18: error: reference to ‘max’ is ambiguous 18 | if (tmp==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:5:18: note: ‘int max’ 5 | int n, p=0, u=0, max=0, i; | ^~~
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ă.