#4216
Scrieţi definiția completă a subprogramului C++ cu antetul:
int EliminaElemente(int a[], int n, int m)
Subprogramul returnează numărul minim de numere distincte care pot să rămână în a după eliminarea a exact m elemente.
Folclorul informatic
| Problema | EliminaElemente | Operații I/O |
eliminaelemente.in/eliminaelemente.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 32 MB
|
| Id soluție | #64810891 | Utilizator | |
| Fișier | eliminaelemente.cpp | Dimensiune | 572 B |
| Data încărcării | 02 Iunie 2026, 20:15 | Scor/rezultat | 90 puncte |
eliminaelemente.cpp: In function ‘int EliminaElemente(int*, int, int)’: eliminaelemente.cpp:13:14: warning: iteration 999 invokes undefined behavior [-Waggressive-loop-optimizations] 13 | v[i] = 0; | ~~~~~^~~ eliminaelemente.cpp:11:19: note: within this loop 11 | for (i = 1; i <= 1000; i++) | ~~^~~~~~~ eliminaelemente.cpp:34:11: warning: iteration 1000 invokes undefined behavior [-Waggressive-loop-optimizations] 34 | if(v[i] > 0) | ~~~^ eliminaelemente.cpp:32:15: note: within this loop 32 | for (i = 0; i < 1001; i++) | ~~^~~~~~ eliminaelemente.cpp:19:9: warning: array subscript 1001 is outside array bounds of ‘int [1000]’ [-Warray-bounds=] 19 | sort(v, v + 1001); | ~~~~^~~~~~~~~~~~~ eliminaelemente.cpp:8:9: note: at offset 4004 into object ‘v’ of size 4000 8 | int v[1000]; | ^ eliminaelemente.cpp:19:9: warning: array subscript 1001 is outside array bounds of ‘int [1000]’ [-Warray-bounds=] 19 | sort(v, v + 1001); | ~~~~^~~~~~~~~~~~~ eliminaelemente.cpp:8:9: note: at offset 4004 into object ‘v’ of size 4000 8 | int v[1000]; | ^ eliminaelemente.cpp:13:14: warning: ‘void* __builtin_memset(void*, int, long unsigned int)’ forming offset [4000, 4003] is out of the bounds [0, 4000] of object ‘v’ with type ‘int [1000]’ [-Warray-bounds=] 13 | v[i] = 0; | ~~~~~^~~ eliminaelemente.cpp:8:9: note: ‘v’ declared here 8 | int v[1000]; | ^
| Test | Timp | Mesaj evaluare | Scor posibil | Scor obținut | ||
|---|---|---|---|---|---|---|
| 0 | 0.001 secunde | OK. | 5 | 5 | ||
| 1 | 0.001 secunde | OK. | 10 | 10 | ||
| 2 | 0.002 secunde | OK. | 10 | 10 | ||
| 3 | 0.002 secunde | Raspuns gresit. | 10 | 0 | ||
| 4 | 0.002 secunde | OK. | 10 | 10 | ||
| 5 | 0.002 secunde | OK. | 10 | 10 | ||
| 6 | 0.002 secunde | OK. | 10 | 10 | ||
| 7 | 0.003 secunde | OK. | 10 | 10 | ||
| 8 | 0.002 secunde | OK. | 10 | 10 | ||
| 9 | 0.002 secunde | OK. | 10 | 10 | ||
| 10 | 0.001 secunde | OK. | 5 | 5 | Exemplu | |
| Punctaj total | 90 | |||||
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema EliminaElemente face parte din a doua categorie. Pentru aceste probleme se folosește un program suport, furnizat de propunătorul problemei. 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ă.