#3011
Se dă un șir a[1], a[2], …, a[n] de numere naturale și un număr natural k. Să se determine cele mai mari k numere din șir.
Folclorul informatic
| Problema | lastk | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.5 secunde | Limita memorie |
Total: 2 MB
/
Stivă 1 MB
|
| Id soluție | #57498281 | Utilizator | |
| Fișier | lastk.cpp | Dimensiune | 2.17 KB |
| Data încărcării | 02 Aprilie 2025, 13:28 | Scor/rezultat | Eroare de compilare |
lastk.cpp: In function 'void urcare(int)': lastk.cpp:18:20: error: 'heap' was not declared in this scope while(pos>1 && heap[pos] < heap[parent(pos)]){ ^ lastk.cpp: In function 'void inserare(int)': lastk.cpp:25:5: error: 'heap' was not declared in this scope heap[sz]=x; ^ lastk.cpp: In function 'long int minim()': lastk.cpp:29:12: error: 'heap' was not declared in this scope return heap[1]; ^ lastk.cpp: In function 'void coborare(int)': lastk.cpp:35:33: error: 'heap' was not declared in this scope if(rightSon(pos)<=sz && heap[rightSon(pos)]<heap[next_pos]){ ^ lastk.cpp:38:12: error: 'heap' was not declared in this scope if(heap[pos]>heap[next_pos]){ ^ lastk.cpp: In function 'void removeMin()': lastk.cpp:46:15: error: 'heap' was not declared in this scope std::swap(heap[1],heap[sz]); ^ lastk.cpp: In function 'void afis()': lastk.cpp:53:16: error: 'heap' was not declared in this scope std::cout<<heap[i]<<" "; ^ lastk.cpp: In function 'int main()': lastk.cpp:95:10: warning: unused variable 'heap' [-Wunused-variable] long heap[k+1]; ^ lastk.cpp: In function 'long int minim()': lastk.cpp:30:1: warning: control reaches end of non-void function [-Wreturn-type] } ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema lastk 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ă.