#1801
forcoding
La un concurs au participat N
elevi, fiecare având punctaj un număr natural. Comisia dorește să găsească un subșir de sumă maximă, punând următoarea condiție: pentru fiecare elev există o limită atât la stânga left []
cât și la dreapta right []
în care nu se mai poate alege un alt elev. Cu alte cuvinte, dacă am selectat punctajul elevului i
pentru subșir, nu mai putem selecta un elev din intervalul [ i-left[i] , i+right[i] ]
.
Ajutați comisia să găsească subșirul de sumă maximă.
Concursul de Informatica "Spiru Haret" Targu Jiu, ed. I
Problema | forcoding | Operații I/O |
forcoding.in /forcoding.out
|
---|---|---|---|
Limita timp | 1 secunde | Limita memorie |
Total: 16 MB
/
Stivă 8 MB
|
Id soluție | #48611356 | Utilizator | |
Fișier | forcoding.cpp | Dimensiune | 746 B |
Data încărcării | 31 Ianuarie 2024, 04:02 | Scor / rezultat | Eroare de compilare |
forcoding.cpp:5:1: error: expected ',' or ';' before 'ofstream' ofstream cout("forcoding.out") ^ forcoding.cpp: In function 'int main()': forcoding.cpp:21:16: error: reference to 'left' is ambiguous cin >> left[i]; ^ forcoding.cpp:10:5: note: candidates are: int left [10005] int left[10005]; ^ In file included from /usr/include/c++/4.8/ios:42:0, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from forcoding.cpp:1: /usr/include/c++/4.8/bits/ios_base.h:922:3: note: std::ios_base& std::left(std::ios_base&) left(ios_base& __base) ^ forcoding.cpp:23:16: error: reference to 'right' is ambiguous cin >> right[i]; ^ forcoding.cpp:11:5: note: candidates are: int right [10005] int right[10005]; ^ In file included from /usr/include/c++/4.8/ios:42:0, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from forcoding.cpp:1: /usr/include/c++/4.8/bits/ios_base.h:930:3: note: std::ios_base& std::right(std::ios_base&) right(ios_base& __base) ^ forcoding.cpp:28:33: error: reference to 'left' is ambiguous for (int j = 1; j < i - left[i]; j++) ^ forcoding.cpp:10:5: note: candidates are: int left [10005] int left[10005]; ^ In file included from /usr/include/c++/4.8/ios:42:0, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from forcoding.cpp:1: /usr/include/c++/4.8/bits/ios_base.h:922:3: note: std::ios_base& std::left(std::ios_base&) left(ios_base& __base) ^ forcoding.cpp:29:13: error: 'dp' was not declared in this scope if (dp[j] > dp[x] && j + right[j] < i) ^ forcoding.cpp:29:34: error: reference to 'right' is ambiguous if (dp[j] > dp[x] && j + right[j] < i) ^ forcoding.cpp:11:5: note: candidates are: int right [10005] int right[10005]; ^ In file included from /usr/include/c++/4.8/ios:42:0, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from forcoding.cpp:1: /usr/include/c++/4.8/bits/ios_base.h:930:3: note: std::ios_base& std::right(std::ios_base&) right(ios_base& __base) ^ forcoding.cpp:32:9: error: 'dp' was not declared in this scope dp[i] == dp[x] + a[i]; ^ forcoding.cpp:39:18: error: 'sol' was not declared in this scope ma = max(sol, dp[i]); ^ forcoding.cpp:39:23: error: 'dp' was not declared in this scope ma = max(sol, dp[i]); ^ forcoding.cpp:41:2: error: 'cout' was not declared in this scope cout << ma; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema forcoding 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ă.