#4301
A venit ora mesei pentru Por Costel (masa dintre prânz și cină). Scormonind printr-o grădină, el descoperă un număr de N coceni de porumb și M mere. Masa lui Por Costel va consta în exact un cocean și un măr. Însă, mai nou, fanii săi l-au atenționat că trebuie să aibă grijă ce mănâncă. Fiecare cocean și fiecare măr are o valoare nutritivă. Valoarea nutritivă a mesei va fi valoarea nutritivă a coceanului ales + valoarea nutritiva a mărului ales. Dându-se valorile nutritive ale cocenilor și ale merelor, Por Costel vă întreabă dacă există o masă pe care o poate lua cu valoare nutritivă X. Pentru că Por Costel vrea sa mănânce de mai multe ori între prânz și cină, el va vă pune T întrebări de forma aceasta.
(Întrebările sunt independente între ele, a nu se considera că după o întrebare se elimină perechea cocean-mar aleasă).
Selecție pe școală, C.N. "Frații Buzești" - 2015, clasa a X-a
| Problema | gustare | Operații I/O |
gustare.in/gustare.out
|
|---|---|---|---|
| Limita timp | 0.4 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64702356 | Utilizator | |
| Fișier | gustare.cpp | Dimensiune | 472 B |
| Data încărcării | 25 Mai 2026, 08:31 | Scor/rezultat | Eroare de compilare |
gustare.cpp:4:1: error: expected ‘,’ or ‘;’ before ‘ofstream’ 4 | ofstream g("gustare.out") | ^~~~~~~~ gustare.cpp: In function ‘int main()’: gustare.cpp:7:5: error: ‘n’ was not declared in this scope 7 | {f>>n>>m; | ^ gustare.cpp:7:8: error: ‘m’ was not declared in this scope; did you mean ‘tm’? 7 | {f>>n>>m; | ^ | tm gustare.cpp:8:6: error: ‘i’ was not declared in this scope 8 | for(i=1;i<=n;i++) | ^ gustare.cpp:9:5: error: ‘mere’ was not declared in this scope 9 | f>>mere[i]; | ^~~~ gustare.cpp:10:6: error: ‘j’ was not declared in this scope 10 | for(j=1;j<=m;j++) | ^ gustare.cpp:11:5: error: ‘coceni’ was not declared in this scope 11 | f>>coceni[i]; | ^~~~~~ gustare.cpp:11:12: error: ‘i’ was not declared in this scope 11 | f>>coceni[i]; | ^ gustare.cpp:12:5: error: ‘t’ was not declared in this scope; did you mean ‘tm’? 12 | f>>t; | ^ | tm gustare.cpp:13:6: error: ‘k’ was not declared in this scope 13 | for(k=1;k<=t;k++) | ^ gustare.cpp:14:6: error: ‘x’ was not declared in this scope 14 | {f>>x; | ^ gustare.cpp:15:3: error: ‘ok’ was not declared in this scope 15 | ok=0; | ^~ gustare.cpp:16:7: error: ‘i’ was not declared in this scope 16 | for(i=1;i<=n;i++) | ^ gustare.cpp:17:8: error: ‘j’ was not declared in this scope 17 | {for(j=1;j<=m;j++) | ^ gustare.cpp:18:7: warning: init-statement in selection statements only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 18 | {if(coceni[i]+mere[i]==x; | ^~~~~~ gustare.cpp:18:7: error: ‘coceni’ was not declared in this scope gustare.cpp:18:17: error: ‘mere’ was not declared in this scope 18 | {if(coceni[i]+mere[i]==x; | ^~~~ gustare.cpp:19:6: error: expected primary-expression before ‘{’ token 19 | {ok=1; | ^ gustare.cpp:18:28: error: expected ‘)’ before ‘{’ token 18 | {if(coceni[i]+mere[i]==x; | ~ ^ | ) 19 | {ok=1; | ~ gustare.cpp:21:6: error: expected primary-expression before ‘}’ token 21 | } | ^ gustare.cpp:23:15: error: expected ‘)’ before ‘}’ token 23 | if(ok==1} | ~ ^ | ) gustare.cpp:23:15: error: expected primary-expression before ‘}’ token gustare.cpp:24:10: error: ‘cout’ was not declared in this scope 24 | cout<<"DA"; | ^~~~ gustare.cpp:2:1: note: ‘std::cout’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’? 1 | #include <fstream> +++ |+#include <iostream> 2 | using namespace std; gustare.cpp:25:10: error: ‘else’ without a previous ‘if’ 25 | else | ^~~~ gustare.cpp:26:21: error: expected ‘}’ at end of input 26 | cout<<"NU"; | ^ gustare.cpp:7:1: note: to match this ‘{’ 7 | {f>>n>>m; | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema gustare 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ă.