#1340
Rucsac
Într-un magazin sunt n
obiecte; pentru fiecare se cunoaște greutatea G
și valoarea V
. Un hoț intră în magazin având un rucsac ce poate transporta o greutate maximă GMax
. El va fura anumite obiecte, sau porțiuni de obiecte, astfel încât suma greutăților obiectelor furate să nu depășească GMax
.
Să se stabilească câștigul maxim pe care îl poate obține hoțul. Câștigul este egal cu suma valorilor obiectelor furate. Câștigul adus de o fracțiune de obiect este direct proporțional cu greutatea fracțiunii.
Problema | Rucsac | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #43705741 | Utilizator | |
Fișier | rucsac.cpp | Dimensiune | 841 B |
Data încărcării | 11 Mai 2023, 07:42 | Scor / rezultat | Eroare de compilare |
rucsac.cpp:6:1: error: stray '\302' in program float c; ^ rucsac.cpp:6:1: error: stray '\240' in program rucsac.cpp:10:1: error: stray '\302' in program return 1; ^ rucsac.cpp:10:1: error: stray '\240' in program rucsac.cpp:10:1: error: stray '\302' in program rucsac.cpp:10:1: error: stray '\240' in program rucsac.cpp:10:1: error: stray '\302' in program rucsac.cpp:10:1: error: stray '\240' in program rucsac.cpp:11:1: error: stray '\302' in program return 0; ^ rucsac.cpp:11:1: error: stray '\240' in program rucsac.cpp:11:1: error: stray '\302' in program rucsac.cpp:11:1: error: stray '\240' in program rucsac.cpp:17:1: error: stray '\302' in program cin >> n >>; Gmax; ^ rucsac.cpp:17:1: error: stray '\240' in program rucsac.cpp:17:1: error: stray '\302' in program rucsac.cpp:17:1: error: stray '\240' in program rucsac.cpp:18:1: error: stray '\302' in program for (int i=0; i<n; i++) ^ rucsac.cpp:18:1: error: stray '\240' in program rucsac.cpp:18:1: error: stray '\302' in program rucsac.cpp:18:1: error: stray '\240' in program rucsac.cpp:19:1: error: stray '\302' in program { ^ rucsac.cpp:19:1: error: stray '\240' in program rucsac.cpp:19:1: error: stray '\302' in program rucsac.cpp:19:1: error: stray '\240' in program rucsac.cpp:20:1: error: stray '\302' in program cin >> x[i].a>>;x[i].b; ^ rucsac.cpp:20:1: error: stray '\240' in program rucsac.cpp:20:1: error: stray '\302' in program rucsac.cpp:20:1: error: stray '\240' in program rucsac.cpp:20:1: error: stray '\302' in program rucsac.cpp:20:1: error: stray '\240' in program rucsac.cpp:20:1: error: stray '\302' in program rucsac.cpp:20:1: error: stray '\240' in program rucsac.cpp:21:1: error: stray '\302' in program x[i].c = (float)x[i].b/x[i].a; ^ rucsac.cpp:21:1: error: stray '\240' in program rucsac.cpp:21:1: error: stray '\302' in program rucsac.cpp:21:1: error: stray '\240' in program rucsac.cpp:21:1: error: stray '\302' in program rucsac.cpp:21:1: error: stray '\240' in program rucsac.cpp:21:1: error: stray '\302' in program rucsac.cpp:21:1: error: stray '\240' in program rucsac.cpp:22:1: error: stray '\302' in program } ^ rucsac.cpp:22:1: error: stray '\240' in program rucsac.cpp:22:1: error: stray '\302' in program rucsac.cpp:22:1: error: stray '\240' in program rucsac.cpp:23:1: error: stray '\302' in program sort(x,x+n,compare); ^ rucsac.cpp:23:1: error: stray '\240' in program rucsac.cpp:23:1: error: stray '\302' in program rucsac.cpp:23:1: error: stray '\240' in program rucsac.cpp:24:1: error: stray '\302' in program for (int i=0; i<n && G<Gmax; i++) ^ rucsac.cpp:24:1: error: stray '\240' in program rucsac.cpp:24:1: error: stray '\302' in program rucsac.cpp:24:1: error: stray '\240' in program rucsac.cpp:25:1: error: stray '\302' in program { ^ rucsac.cpp:25:1: error: stray '\240' in program rucsac.cpp:25:1: error: stray '\302' in program rucsac.cpp:25:1: error: stray '\240' in program rucsac.cpp:26:1: error: stray '\302' in program ^ rucsac.cpp:26:1: error: stray '\240' in program rucsac.cpp:26:1: error: stray '\302' in program rucsac.cpp:26:1: error: stray '\240' in program rucsac.cpp:26:1: error: stray '\302' in program rucsac.cpp:26:1: error: stray '\240' in program rucsac.cpp:27:1: error: stray '\302' in program if (G+x[i].a <= Gmax) ^ rucsac.cpp:27:1: error: stray '\240' in program rucsac.cpp:27:1: error: stray '\302' in program rucsac.cpp:27:1: error: stray '\240' in program rucsac.cpp:27:1: error: stray '\302' in program rucsac.cpp:27:1: error: stray '\240' in program rucsac.cpp:27:1: error: stray '\302' in program rucsac.cpp:27:1: error: stray '\240' in program rucsac.cpp:28:1: error: stray '\302' in program { ^ rucsac.cpp:28:1: error: stray '\240' in program rucsac.cpp:28:1: error: stray '\302' in program rucsac.cpp:28:1: error: stray '\240' in program rucsac.cpp:28:1: error: stray '\302' in program rucsac.cpp:28:1: error: stray '\240' in program rucsac.cpp:28:1: error: stray '\302' in program rucsac.cpp:28:1: error: stray '\240' in program rucsac.cpp:29:1: error: stray '\302' in program C+=x[i].b; ^ rucsac.cpp:29:1: error: stray '\240' in program rucsac.cpp:29:1: error: stray '\302' in program rucsac.cpp:29:1: error: stray '\240' in program rucsac.cpp:29:1: error: stray '\302' in program rucsac.cpp:29:1: error: stray '\240' in program rucsac.cpp:29:1: error: stray '\302' in program rucsac.cpp:29:1: error: stray '\240' in program rucsac.cpp:29:1: error: stray '\302' in program rucsac.cpp:29:1: error: stray '\240' in program rucsac.cpp:29:1: error: stray '\302' in program rucsac.cpp:29:1: error: stray '\240' in program rucsac.cpp:30:1: error: stray '\302' in program G+=x[i].a; ^ rucsac.cpp:30:1: error: stray '\240' in program rucsac.cpp:30:1: error: stray '\302' in program rucsac.cpp:30:1: error: stray '\240' in program rucsac.cpp:30:1: error: stray '\302' in program rucsac.cpp:30:1: error: stray '\240' in program rucsac.cpp:30:1: error: stray '\302' in program rucsac.cpp:30:1: error: stray '\240' in program rucsac.cpp:30:1: error: stray '\302' in program rucsac.cpp:30:1: error: stray '\240' in program rucsac.cpp:30:1: error: stray '\302' in program rucsac.cpp:30:1: error: stray '\240' in program rucsac.cpp:31:1: error: stray '\302' in program } ^ rucsac.cpp:31:1: error: stray '\240' in program rucsac.cpp:31:1: error: stray '\302' in program rucsac.cpp:31:1: error: stray '\240' in program rucsac.cpp:31:1: error: stray '\302' in program rucsac.cpp:31:1: error: stray '\240' in program rucsac.cpp:31:1: error: stray '\302' in program rucsac.cpp:31:1: error: stray '\240' in program rucsac.cpp:32:1: error: stray '\302' in program else ^ rucsac.cpp:32:1: error: stray '\240' in program rucsac.cpp:32:1: error: stray '\302' in program rucsac.cpp:32:1: error: stray '\240' in program rucsac.cpp:32:1: error: stray '\302' in program rucsac.cpp:32:1: error: stray '\240' in program rucsac.cpp:32:1: error: stray '\302' in program rucsac.cpp:32:1: error: stray '\240' in program rucsac.cpp:33:1: error: stray '\302' in program if (G+x[i].a > Gmax) ^ rucsac.cpp:33:1: error: stray '\240' in program rucsac.cpp:33:1: error: stray '\302' in program rucsac.cpp:33:1: error: stray '\240' in program rucsac.cpp:33:1: error: stray '\302' in program rucsac.cpp:33:1: error: stray '\240' in program rucsac.cpp:33:1: error: stray '\302' in program rucsac.cpp:33:1: error: stray '\240' in program rucsac.cpp:34:1: error: stray '\302' in program { ^ rucsac.cpp:34:1: error: stray '\240' in program rucsac.cpp:34:1: error: stray '\302' in program rucsac.cpp:34:1: error: stray '\240' in program rucsac.cpp:34:1: error: stray '\302' in program rucsac.cpp:34:1: error: stray '\240' in program rucsac.cpp:34:1: error: stray '\302' in program rucsac.cpp:34:1: error: stray '\240' in program rucsac.cpp:35:1: error: stray '\302' in program C+=(Gmax-G)*(float)x[i].b/x[i].a; ^ rucsac.cpp:35:1: error: stray '\240' in program rucsac.cpp:35:1: error: stray '\302' in program rucsac.cpp:35:1: error: stray '\240' in program rucsac.cpp:35:1: error: stray '\302' in program rucsac.cpp:35:1: error: stray '\240' in program rucsac.cpp:35:1: error: stray '\302' in program rucsac.cpp:35:1: error: stray '\240' in program rucsac.cpp:35:1: error: stray '\302' in program rucsac.cpp:35:1: error: stray '\240' in program rucsac.cpp:35:1: error: stray '\302' in program rucsac.cpp:35:1: error: stray '\240' in program rucsac.cpp:36:1: error: stray '\302' in program G=Gmax; ^ rucsac.cpp:36:1: error: stray '\240' in program rucsac.cpp:36:1: error: stray '\302' in program rucsac.cpp:36:1: error: stray '\240' in program rucsac.cpp:36:1: error: stray '\302' in program rucsac.cpp:36:1: error: stray '\240' in program rucsac.cpp:36:1: error: stray '\302' in program rucsac.cpp:36:1: error: stray '\240' in program rucsac.cpp:36:1: error: stray '\302' in program rucsac.cpp:36:1: error: stray '\240' in program rucsac.cpp:36:1: error: stray '\302' in program rucsac.cpp:36:1: error: stray '\240' in program rucsac.cpp:37:1: error: stray '\302' in program break; ^ rucsac.cpp:37:1: error: stray '\240' in program rucsac.cpp:37:1: error: stray '\302' in program rucsac.cpp:37:1: error: stray '\240' in program rucsac.cpp:37:1: error: stray '\302' in program rucsac.cpp:37:1: error: stray '\240' in program rucsac.cpp:37:1: error: stray '\302' in program rucsac.cpp:37:1: error: stray '\240' in program rucsac.cpp:37:1: error: stray '\302' in program rucsac.cpp:37:1: error: stray '\240' in program rucsac.cpp:37:1: error: stray '\302' in program rucsac.cpp:37:1: error: stray '\240' in program rucsac.cpp:38:1: error: stray '\302' in program } ^ rucsac.cpp:38:1: error: stray '\240' in program rucsac.cpp:38:1: error: stray '\302' in program rucsac.cpp:38:1: error: stray '\240' in program rucsac.cpp:38:1: error: stray '\302' in program rucsac.cpp:38:1: error: stray '\240' in program rucsac.cpp:38:1: error: stray '\302' in program rucsac.cpp:38:1: error: stray '\240' in program rucsac.cpp:39:1: error: stray '\302' in program } ^ rucsac.cpp:39:1: error: stray '\240' in program rucsac.cpp:39:1: error: stray '\302' in program rucsac.cpp:39:1: error: stray '\240' in program rucsac.cpp:40:1: error: stray '\302' in program cout << C; ^ rucsac.cpp:40:1: error: stray '\240' in program rucsac.cpp:40:1: error: stray '\302' in program rucsac.cpp:40:1: error: stray '\240' in program rucsac.cpp:40:1: error: stray '\302' in program rucsac.cpp:40:1: error: stray '\240' in program rucsac.cpp:40:1: error: stray '\302' in program rucsac.cpp:40:1: error: stray '\240' in program rucsac.cpp:41:1: error: stray '\302' in program return 0; ^ rucsac.cpp:41:1: error: stray '\240' in program rucsac.cpp:41:1: error: stray '\302' in program rucsac.cpp:41:1: error: stray '\240' in program rucsac.cpp:41:1: error: stray '\302' in program rucsac.cpp:41:1: error: stray '\240' in program rucsac.cpp:41:1: error: stray '\302' in program rucsac.cpp:41:1: error: stray '\240' in program rucsac.cpp: In function 'int main()': rucsac.cpp:17:18: error: expected primary-expression before ';' token cin >> n >>; Gmax; ^ rucsac.cpp:17:24: warning: statement has no effect [-Wunused-value] cin >> n >>; Gmax; ^ rucsac.cpp:20:28: error: expected primary-expression before ';' token cin >> x[i].a>>;x[i].b; ^ rucsac.cpp:20:35: warning: statement has no effect [-Wunused-value] cin >> x[i].a>>;x[i].b; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Rucsac 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ă.