#4219
Scrieţi definiția completă a subprogramului C++ cu antetul:
int Egalitate(int a[], int n)
Subprogramul returnează numărul minim de elemente care pot fi eliminate astfel încât fiecare număr rămas în vector să aibă aceeași frecvență de apariție.
Folclorul informatic
| Problema | Egalitate | Operații I/O |
egalitate.in/egalitate.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 32 MB
|
| Id soluție | #60003962 | Utilizator | |
| Fișier | egalitate.cpp | Dimensiune | 1.39 KB |
| Data încărcării | 15 Octombrie 2025, 11:35 | Scor/rezultat | Eroare de compilare |
egalitate.cpp:4:1: error: stray '\310' in program Mai jos ai definiția completă a subprogramului cerut. E eficientă (O(n + M) unde M ≤ 1000 — limita valorilor), și returnează numărul minim de elemente de eliminat pentru ca toate valorile rămase să aibă aceeași frecvență. ^ egalitate.cpp:4:1: error: stray '\233' in program egalitate.cpp:4:1: error: stray '\304' in program egalitate.cpp:4:1: error: stray '\203' in program egalitate.cpp:4:1: error: stray '\304' in program egalitate.cpp:4:1: error: stray '\203' in program egalitate.cpp:4:1: error: stray '\342' in program egalitate.cpp:4:1: error: stray '\211' in program egalitate.cpp:4:1: error: stray '\244' in program egalitate.cpp:4:1: error: stray '\342' in program egalitate.cpp:4:1: error: stray '\200' in program egalitate.cpp:4:1: error: stray '\224' in program egalitate.cpp:4:1: error: stray '\310' in program egalitate.cpp:4:1: error: stray '\231' in program egalitate.cpp:4:1: error: stray '\304' in program egalitate.cpp:4:1: error: stray '\203' in program egalitate.cpp:4:1: error: stray '\304' in program egalitate.cpp:4:1: error: stray '\203' in program egalitate.cpp:4:1: error: stray '\304' in program egalitate.cpp:4:1: error: stray '\203' in program egalitate.cpp:4:1: error: stray '\304' in program egalitate.cpp:4:1: error: stray '\203' in program egalitate.cpp:4:1: error: stray '\304' in program egalitate.cpp:4:1: error: stray '\203' in program egalitate.cpp:4:1: error: stray '\310' in program egalitate.cpp:4:1: error: stray '\231' in program egalitate.cpp:4:1: error: stray '\310' in program egalitate.cpp:4:1: error: stray '\233' in program egalitate.cpp:4:1: error: stray '\304' in program egalitate.cpp:4:1: error: stray '\203' in program egalitate.cpp:35:1: error: stray '\310' in program Explicație scurtă: pentru o frecvență țintă t, păstrăm toate valorile care apar cel puțin t ori (pentru fiecare păstrăm t copii) — pentru rest le eliminăm complet. Costul total devine n - t * count_ge_t. Alegem t care minimizează acest cost. ^ egalitate.cpp:35:1: error: stray '\233' in program egalitate.cpp:35:1: error: stray '\304' in program egalitate.cpp:35:1: error: stray '\203' in program egalitate.cpp:35:1: error: stray '\310' in program egalitate.cpp:35:1: error: stray '\233' in program egalitate.cpp:35:1: error: stray '\304' in program egalitate.cpp:35:1: error: stray '\203' in program egalitate.cpp:35:1: error: stray '\310' in program egalitate.cpp:35:1: error: stray '\233' in program egalitate.cpp:35:1: error: stray '\304' in program egalitate.cpp:35:1: error: stray '\203' in program egalitate.cpp:35:1: error: stray '\304' in program egalitate.cpp:35:1: error: stray '\203' in program egalitate.cpp:35:1: error: stray '\304' in program egalitate.cpp:35:1: error: stray '\203' in program egalitate.cpp:35:1: error: stray '\310' in program egalitate.cpp:35:1: error: stray '\233' in program egalitate.cpp:35:1: error: stray '\304' in program egalitate.cpp:35:1: error: stray '\203' in program egalitate.cpp:35:1: error: stray '\304' in program egalitate.cpp:35:1: error: stray '\203' in program egalitate.cpp:35:1: error: stray '\342' in program egalitate.cpp:35:1: error: stray '\200' in program egalitate.cpp:35:1: error: stray '\224' in program egalitate.cpp:35:1: error: stray '\304' in program egalitate.cpp:35:1: error: stray '\203' in program egalitate.cpp:35:1: error: stray '\304' in program egalitate.cpp:35:1: error: stray '\203' in program egalitate.cpp:4:1: error: 'Mai' does not name a type Mai jos ai definiția completă a subprogramului cerut. E eficientă (O(n + M) unde M ≤ 1000 — limita valorilor), și returnează numărul minim de elemente de eliminat pentru ca toate valorile rămase să aibă aceeași frecvență. ^ egalitate.cpp:35:1: error: 'Explica' does not name a type Explicație scurtă: pentru o frecvență țintă t, păstrăm toate valorile care apar cel puțin t ori (pentru fiecare păstrăm t copii) — pentru rest le eliminăm complet. Costul total devine n - t * count_ge_t. Alegem t care minimizează acest cost. ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Egalitate 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ă.