#1591
Se dă un şir de N numere întregi. Definim costul intervalului [x, y], unde x si y apartin {1, 2, …, N}, ca fiind suma diferenţelor dintre numărul maxim din șir, aflat în interval şi restul numerelor aflate pe pozițiile x, x+1, …, y.
De exemplu, pentru şirul 2 4 7 4 3 -1 2 4 6 costul intervalului [3, 6] este 15. (explicație: 7-7+ 7-4 + 7-3 + 7+1 = 15).
Se definesc M operaţii de forma tip x y, astfel: Dacă tip este 1, atunci elementul de pe poziţia x din șir devine y. Dacă tip este 2, atunci să se afişeze costul intervalului [x, y].
Să se determine răspunsul pentru fiecare operaţie de tipul 2.
Info-Oltenia 2015
| Problema | Intervalxy | Operații I/O |
intervalxy.in/intervalxy.out
|
|---|---|---|---|
| Limita timp | 0.2 secunde | Limita memorie |
Total: 32 MB
/
Stivă 2 MB
|
| Id soluție | #38024065 | Utilizator | |
| Fișier | intervalxy.cpp | Dimensiune | 1.93 KB |
| Data încărcării | 27 Septembrie 2022, 18:48 | Scor/rezultat | 25 puncte |
intervalxy.cpp: In function 'int main()': intervalxy.cpp:87:17: warning: unused variable 'v1' [-Wunused-variable] int v1= calcul_max(1, 1, p, x, y); ^ intervalxy.cpp:88:17: warning: unused variable 'v2' [-Wunused-variable] int v2= calcul_sum(1, 1, p, x, y); ^ intervalxy.cpp:57:41: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result] freopen("intervalxy.in", "r", stdin); ^ intervalxy.cpp:58:43: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result] freopen("intervalxy.out", "w", stdout); ^ intervalxy.cpp:60:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ intervalxy.cpp:69:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &x); ^ intervalxy.cpp:74:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &m); ^ intervalxy.cpp:77:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d%d", &c,&x, &y); ^
| Test | Timp | Mesaj evaluare | Scor posibil | Scor obținut | ||
|---|---|---|---|---|---|---|
| 0 | 0 secunde | OK. | 1 | 1 | ||
| 1 | 0 secunde | OK. | 1 | 1 | ||
| 2 | 0 secunde | OK. | 1 | 1 | ||
| 3 | 0 secunde | OK. | 1 | 1 | ||
| 4 | 0 secunde | OK. | 1 | 1 | ||
| 5 | 0 secunde | OK. | 2 | 2 | ||
| 6 | 0 secunde | OK. | 2 | 2 | ||
| 7 | 0 secunde | OK. | 2 | 2 | ||
| 8 | 0 secunde | OK. | 2 | 2 | ||
| 9 | 0 secunde | OK. | 2 | 2 | ||
| 10 | 0 secunde | OK. | 2 | 2 | ||
| 11 | 0 secunde | OK. | 2 | 2 | ||
| 12 | 0.004 secunde | OK. | 2 | 2 | ||
| 13 | 0.004 secunde | OK. | 2 | 2 | ||
| 14 | 0.004 secunde | OK. | 2 | 2 | ||
| 15 | 0.076 secunde | Raspuns gresit. | 5 | 0 | ||
| 16 | 0.04 secunde | Raspuns gresit. | 5 | 0 | ||
| 17 | 0.088 secunde | Raspuns gresit. | 5 | 0 | ||
| 18 | 0.06 secunde | Raspuns gresit. | 5 | 0 | ||
| 20 | 0.048 secunde | Raspuns gresit. | 5 | 0 | ||
| 21 | 0.08 secunde | Raspuns gresit. | 5 | 0 | ||
| 22 | 0.088 secunde | Raspuns gresit. | 5 | 0 | ||
| 23 | 0.072 secunde | Raspuns gresit. | 5 | 0 | ||
| 24 | 0.112 secunde | Raspuns gresit. | 5 | 0 | ||
| 25 | 0.1 secunde | Raspuns gresit. | 6 | 0 | ||
| 26 | 0.112 secunde | Raspuns gresit. | 6 | 0 | ||
| 27 | 0.124 secunde | Raspuns gresit. | 6 | 0 | ||
| 28 | 0.124 secunde | Raspuns gresit. | 6 | 0 | ||
| 29 | 0.12 secunde | Raspuns gresit. | 6 | 0 | ||
| Punctaj total | 25 | |||||
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Intervalxy 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ă.