#4720
Fie un șir de n numere naturale și un număr natural k. Să se determine numărul maxim de numere distincte care pot rămâne după eliminarea unei secvențe de k elemente din șir.
Problema de interviu
| Problema | MaxDistincte | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64172404 | Utilizator | |
| Fișier | maxdistincte.cpp | Dimensiune | 1.35 KB |
| Data încărcării | 21 Aprilie 2026, 15:03 | Scor/rezultat | 100 puncte |
maxdistincte.cpp: In function ‘int main()’: maxdistincte.cpp:40:19: warning: iteration 100000 invokes undefined behavior [-Waggressive-loop-optimizations] 40 | inside[i] = 0; | ~~~~~~~~~~^~~ maxdistincte.cpp:38:23: note: within this loop 38 | for (int i = 0; i <= 100000; i++) | ~~^~~~~~~~~ maxdistincte.cpp:40:19: warning: ‘void* __builtin_memset(void*, int, long unsigned int)’ forming offset [400000, 400003] is out of the bounds [0, 400000] of object ‘inside’ with type ‘int [100000]’ [-Warray-bounds=] 40 | inside[i] = 0; | ~~~~~~~~~~^~~ maxdistincte.cpp:36:9: note: ‘inside’ declared here 36 | int inside[100000]; | ^~~~~~
| Test | Timp | Mesaj evaluare | Scor posibil | Scor obținut | ||
|---|---|---|---|---|---|---|
| 0 | 0.002 secunde | OK. | 5 | 5 | ||
| 1 | 0.002 secunde | OK. | 5 | 5 | ||
| 2 | 0.004 secunde | OK. | 5 | 5 | ||
| 3 | 0.002 secunde | OK. | 5 | 5 | ||
| 4 | 0.002 secunde | OK. | 5 | 5 | ||
| 5 | 0.002 secunde | OK. | 5 | 5 | ||
| 6 | 0.002 secunde | OK. | 5 | 5 | ||
| 7 | 0.004 secunde | OK. | 5 | 5 | ||
| 8 | 0.002 secunde | OK. | 5 | 5 | ||
| 9 | 0.002 secunde | OK. | 5 | 5 | ||
| 10 | 0.003 secunde | OK. | 5 | 5 | ||
| 11 | 0.004 secunde | OK. | 5 | 5 | ||
| 12 | 0.008 secunde | OK. | 5 | 5 | ||
| 13 | 0.011 secunde | OK. | 5 | 5 | ||
| 14 | 0.014 secunde | OK. | 5 | 5 | ||
| 15 | 0.021 secunde | OK. | 5 | 5 | ||
| 16 | 0.016 secunde | OK. | 5 | 5 | ||
| 17 | 0.015 secunde | OK. | 5 | 5 | ||
| 18 | 0.014 secunde | OK. | 5 | 5 | ||
| 19 | 0.018 secunde | OK. | 5 | 5 | ||
| Punctaj total | 100 | |||||
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema MaxDistincte 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ă.