#1696
Perechi2
Fie un şir a[1]
, a[2]
, …, a[n]
de numere naturale, unde n
este impar. Avem la dispoziţie o singură operaţie admisă şi anume: putem aduna la două poziţii diferite din şir o aceeaşi valoare naturală nenulă.
Cerințe:
ONI 2016, clasa a V-a
Problema | Perechi2 | Operații I/O |
perechi2.in /perechi2.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #29088785 | Utilizator | |
Fișier | perechi2.cpp | Dimensiune | 1.32 KB |
Data încărcării | 30 Martie 2021, 19:32 | Scor / rezultat | Eroare de compilare |
perechi2.cpp: In function 'int main()': perechi2.cpp:16:5: error: reference to 'cin' is ambiguous cin >> cer >> n; ^ perechi2.cpp:3:10: note: candidates are: std::ifstream cin ifstream cin("perechi2.in"); ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:74:0, from perechi2.cpp:1: /usr/include/c++/4.8/iostream:60:18: note: std::istream std::cin extern istream cin; /// Linked to standard input ^ perechi2.cpp:18:9: error: reference to 'cin' is ambiguous cin >> a[i].val , a[i].ind = i; ^ perechi2.cpp:3:10: note: candidates are: std::ifstream cin ifstream cin("perechi2.in"); ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:74:0, from perechi2.cpp:1: /usr/include/c++/4.8/iostream:60:18: note: std::istream std::cin extern istream cin; /// Linked to standard input ^ perechi2.cpp:26:26: error: reference to 'cout' is ambiguous if(cnt == 0) cout << a[1].ind << " " << a[2].ind << " " << a[3].val - a[1].val; ^ perechi2.cpp:4:10: note: candidates are: std::ofstream cout ofstream cout("perechi2.out"); ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:74:0, from perechi2.cpp:1: /usr/include/c++/4.8/iostream:61:18: note: std::ostream std::cout extern ostream cout; /// Linked to standard output ^ perechi2.cpp:28:14: error: reference to 'cout' is ambiguous else cout << 0; ^ perechi2.cpp:4:10: note: candidates are: std::ofstream cout ofstream cout("perechi2.out"); ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:74:0, from perechi2.cpp:1: /usr/include/c++/4.8/iostream:61:18: note: std::ostream std::cout extern ostream cout; /// Linked to standard output ^ perechi2.cpp:38:13: error: reference to 'cout' is ambiguous cout << a[i].ind << " " << a[i + 1].ind << " " << maxi - A << '\n'; ^ perechi2.cpp:4:10: note: candidates are: std::ofstream cout ofstream cout("perechi2.out"); ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:74:0, from perechi2.cpp:1: /usr/include/c++/4.8/iostream:61:18: note: std::ostream std::cout extern ostream cout; /// Linked to standard output ^ perechi2.cpp:35:32: warning: unused variable 'B' [-Wunused-variable] int A = a[i].val , B = a[i + 1].val; ^ perechi2.cpp:42:9: error: reference to 'cout' is ambiguous cout << a[1].ind << " " << a[n].ind << " " << maxi - a[1].val << '\n'; ^ perechi2.cpp:4:10: note: candidates are: std::ofstream cout ofstream cout("perechi2.out"); ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:74:0, from perechi2.cpp:1: /usr/include/c++/4.8/iostream:61:18: note: std::ostream std::cout extern ostream cout; /// Linked to standard output ^ perechi2.cpp:45:13: error: reference to 'cout' is ambiguous cout << a[i].ind << " " << a[i + 1].ind << " " << maxi - a[i].val << '\n'; ^ perechi2.cpp:4:10: note: candidates are: std::ofstream cout ofstream cout("perechi2.out"); ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:74:0, from perechi2.cpp:1: /usr/include/c++/4.8/iostream:61:18: note: std::ostream std::cout extern ostream cout; /// Linked to standard output ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Perechi2 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ă.