#3262
rain
Bariere impermeabile de înălțimi diferite sunt plasate perpendicular pe lungimea unei cuve dreptunghiulare. Distanța dintre oricare două bariere alăturate este de un centimetru. Cuva nu are capac și atunci când plouă destul, cuva este umplută cu apă. Unele bariere pot fi înălțate cu o valoare întreagă care nu poate depăși o valoare dată. Care este numărul minim de bariere care trebuie înălțate astfel încât să fie colectată în cuvă o cantitate maximă de apă?
Turneul Internațional Shumen 2019
Problema | rain | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.5 secunde | Limita memorie |
Total: 128 MB
/
Stivă 8 MB
|
Id soluție | #43188424 | Utilizator | |
Fișier | rain.cpp | Dimensiune | 1.90 KB |
Data încărcării | 05 Aprilie 2023, 12:46 | Scor / rezultat | Eroare de compilare |
rain.cpp: In function 'int main()': rain.cpp:43:14: error: expected unqualified-id before '[' token auto [new_height, idx] = pq.top(); ^ rain.cpp:45:13: error: 'new_height' was not declared in this scope if (new_height <= heights[idx]) { ^ rain.cpp:45:35: error: 'idx' was not declared in this scope if (new_height <= heights[idx]) { ^ rain.cpp:49:24: error: 'idx' was not declared in this scope int left_idx = idx - 1, right_idx = idx + 1; ^ rain.cpp:50:85: error: 'new_height' was not declared in this scope while (left_idx >= 0 && max_increases[left_idx] == 0 && heights[left_idx] < new_height) { ^ rain.cpp:51:43: error: no matching function for call to 'std::priority_queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)' pq.push({new_height, left_idx}); ^ rain.cpp:51:43: note: candidates are: In file included from /usr/include/c++/4.8/queue:64:0, from rain.cpp:4: /usr/include/c++/4.8/bits/stl_queue.h:496:7: note: void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >; _Compare = std::less<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, int>] push(const value_type& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:496:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::pair<int, int>&}' /usr/include/c++/4.8/bits/stl_queue.h:504:7: note: void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >; _Compare = std::less<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, int>] push(value_type&& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:504:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<int, int> >::value_type&& {aka std::pair<int, int>&&}' rain.cpp:54:16: error: 'right_idx' was not declared in this scope while (right_idx < n && max_increases[right_idx] == 0 && heights[right_idx] < new_height) { ^ rain.cpp:54:87: error: 'new_height' was not declared in this scope while (right_idx < n && max_increases[right_idx] == 0 && heights[right_idx] < new_height) { ^ rain.cpp:55:44: error: no matching function for call to 'std::priority_queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)' pq.push({new_height, right_idx}); ^ rain.cpp:55:44: note: candidates are: In file included from /usr/include/c++/4.8/queue:64:0, from rain.cpp:4: /usr/include/c++/4.8/bits/stl_queue.h:496:7: note: void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >; _Compare = std::less<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, int>] push(const value_type& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:496:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::pair<int, int>&}' /usr/include/c++/4.8/bits/stl_queue.h:504:7: note: void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >; _Compare = std::less<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, int>] push(value_type&& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:504:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<int, int> >::value_type&& {aka std::pair<int, int>&&}' rain.cpp:58:24: error: 'new_height' was not declared in this scope heights[idx] = new_height; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema rain 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ă.