#341
Bomboane
La magazinul din colț au fost aduse n
cutii, numerotate de la 1
la n
, fiecare conținând un anumit număr de bomboane. Administratorul magazinului hotărăște, pentru bunul mers al afacerilor, că bomboanele trebuie rearanjate în cutii, astfel încât fiecare cutie să conțină același număr de bomboane. Pentru aceasta, administratorul magazinului realizează în mod repetat următoarea operație: mută un număr oarecare de bomboane din cutia cu număr maxim de bomboane în cea cu număr minim de bomboane.
Determinați un șir minim de operații prin care toate cutiile conțin același număr de bomboane.
Problema | Bomboane | Operații I/O |
bomboane.in /bomboane.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #54023469 | Utilizator | |
Fișier | bomboane.cpp | Dimensiune | 1.61 KB |
Data încărcării | 18 Noiembrie 2024, 10:10 | Scor / rezultat | Eroare de compilare |
bomboane.cpp: In function 'int main()': bomboane.cpp:42:14: error: expected unqualified-id before '[' token auto [max_candies, max_idx] = max_heap.top(); ^ bomboane.cpp:44:14: error: expected unqualified-id before '[' token auto [min_candies, min_idx] = min_heap.top(); ^ bomboane.cpp:47:28: error: 'max_candies' was not declared in this scope int transfer = min(max_candies - nrb, nrb - min_candies); ^ bomboane.cpp:47:53: error: 'min_candies' was not declared in this scope int transfer = min(max_candies - nrb, nrb - min_candies); ^ bomboane.cpp:49:11: error: 'max_idx' was not declared in this scope v[max_idx] -= transfer; ^ bomboane.cpp:50:11: error: 'min_idx' was not declared in this scope v[min_idx] += transfer; ^ bomboane.cpp:52:58: error: no matching function for call to 'std::vector<std::tuple<int, int, int> >::push_back(<brace-enclosed initializer list>)' operations.push_back({max_idx, min_idx, transfer}); ^ bomboane.cpp:52:58: note: candidates are: In file included from /usr/include/c++/4.8/vector:64:0, from /usr/include/c++/4.8/bits/random.h:34, from /usr/include/c++/4.8/random:50, from /usr/include/c++/4.8/bits/stl_algo.h:65, from /usr/include/c++/4.8/algorithm:62, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from bomboane.cpp:1: /usr/include/c++/4.8/bits/stl_vector.h:901:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; std::vector<_Tp, _Alloc>::value_type = std::tuple<int, int, int>] push_back(const value_type& __x) ^ /usr/include/c++/4.8/bits/stl_vector.h:901:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::tuple<int, int, int>&}' /usr/include/c++/4.8/bits/stl_vector.h:919:7: note: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; std::vector<_Tp, _Alloc>::value_type = std::tuple<int, int, int>] push_back(value_type&& __x) ^ /usr/include/c++/4.8/bits/stl_vector.h:919:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::tuple<int, int, int> >::value_type&& {aka std::tuple<int, int, int>&&}' bomboane.cpp:55:48: error: no matching function for call to 'std::priority_queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)' max_heap.push({v[max_idx], max_idx}); ^ bomboane.cpp:55:48: note: candidates are: In file included from /usr/include/c++/4.8/queue:64:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:85, from bomboane.cpp:1: /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>&&}' bomboane.cpp:57:48: error: no matching function for call to 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >, std::greater<std::pair<int, int> > >::push(<brace-enclosed initializer list>)' min_heap.push({v[min_idx], min_idx}); ^ bomboane.cpp:57:48: note: candidates are: In file included from /usr/include/c++/4.8/queue:64:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:85, from bomboane.cpp:1: /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::greater<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::greater<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>, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >, std::greater<std::pair<int, int> > >::value_type&& {aka std::pair<int, int>&&}'
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Bomboane 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ă.