Detalii evaluare #62731665

Rezumat problemă

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.

Detalii

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 #62731665 Utilizator boncea sofia (Sofiaaaaxa)
Fișier bomboane.cpp Dimensiune 1.43 KB
Data încărcării 31 Ianuarie 2026, 10:20 Scor/rezultat Eroare de compilare

Evaluare

Mesaj compilare

bomboane.cpp: In function 'int main()':
bomboane.cpp:16:5: error: expected initializer before 'for'
     for (i = 1; i <= n; i++)

     ^
bomboane.cpp:16:17: error: 'i' was not declared in this scope
     for (i = 1; i <= n; i++)

                 ^
bomboane.cpp:16:28: error: expected ';' before ')' token
     for (i = 1; i <= n; i++)

                            ^
bomboane.cpp:46:16: error: 'cout' was not declared in this scope
                cout << 0; 

                ^
bomboane.cpp:50:43: error: no match for 'operator-' (operand types are 'int' and 'ura')
                if (v[pozmax].b -med < med -v[pozmin])

                                           ^
bomboane.cpp:50:43: note: candidates are:
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/fstream:38,
                 from bomboane.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:327:5: note: template<class _Iterator> typename std::reverse_iterator<_Iterator>::difference_type std::operator-(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
     operator-(const reverse_iterator<_Iterator>& __x,
     ^
/usr/include/c++/4.8/bits/stl_iterator.h:327:5: note:   template argument deduction/substitution failed:
bomboane.cpp:50:52: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
                if (v[pozmax].b -med < med -v[pozmin])

                                                    ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/fstream:38,
                 from bomboane.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:379:5: note: template<class _IteratorL, class _IteratorR> decltype ((__y.base() - __x.base())) std::operator-(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)
     operator-(const reverse_iterator<_IteratorL>& __x,
     ^
/usr/include/c++/4.8/bits/stl_iterator.h:379:5: note:   template argument deduction/substitution failed:
bomboane.cpp:50:52: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
                if (v[pozmax].b -med < med -v[pozmin])

                                                    ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/fstream:38,
                 from bomboane.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:1104:5: note: template<class _IteratorL, class _IteratorR> decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&)
     operator-(const move_iterator<_IteratorL>& __x,
     ^
/usr/include/c++/4.8/bits/stl_iterator.h:1104:5: note:   template argument deduction/substitution failed:
bomboane.cpp:50:52: note:   mismatched types 'const std::move_iterator<_Iterator>' and 'int'
                if (v[pozmax].b -med < med -v[pozmin])

                                                    ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/fstream:38,
                 from bomboane.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:1111:5: note: template<class _Iterator> decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)
     operator-(const move_iterator<_Iterator>& __x,
     ^
/usr/include/c++/4.8/bits/stl_iterator.h:1111:5: note:   template argument deduction/substitution failed:
bomboane.cpp:50:52: note:   mismatched types 'const std::move_iterator<_Iterator>' and 'int'
                if (v[pozmax].b -med < med -v[pozmin])

                                                    ^
bomboane.cpp:53:25: error: no match for 'operator-' (operand types are 'int' and 'ura')
                 x = med - v[pozmin];

                         ^
bomboane.cpp:53:25: note: candidates are:
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/fstream:38,
                 from bomboane.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:327:5: note: template<class _Iterator> typename std::reverse_iterator<_Iterator>::difference_type std::operator-(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
     operator-(const reverse_iterator<_Iterator>& __x,
     ^
/usr/include/c++/4.8/bits/stl_iterator.h:327:5: note:   template argument deduction/substitution failed:
bomboane.cpp:53:35: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
                 x = med - v[pozmin];

                                   ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/fstream:38,
                 from bomboane.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:379:5: note: template<class _IteratorL, class _IteratorR> decltype ((__y.base() - __x.base())) std::operator-(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)
     operator-(const reverse_iterator<_IteratorL>& __x,
     ^
/usr/include/c++/4.8/bits/stl_iterator.h:379:5: note:   template argument deduction/substitution failed:
bomboane.cpp:53:35: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
                 x = med - v[pozmin];

                                   ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/fstream:38,
                 from bomboane.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:1104:5: note: template<class _IteratorL, class _IteratorR> decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&)
     operator-(const move_iterator<_IteratorL>& __x,
     ^
/usr/include/c++/4.8/bits/stl_iterator.h:1104:5: note:   template argument deduction/substitution failed:
bomboane.cpp:53:35: note:   mismatched types 'const std::move_iterator<_Iterator>' and 'int'
                 x = med - v[pozmin];

                                   ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/fstream:38,
                 from bomboane.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:1111:5: note: template<class _Iterator> decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)
     operator-(const move_iterator<_Iterator>& __x,
     ^
/usr/include/c++/4.8/bits/stl_iterator.h:1111:5: note:   template argument deduction/substitution failed:
bomboane.cpp:53:35: note:   mismatched types 'const std::move_iterator<_Iterator>' and 'int'
                 x = med - v[pozmin];

                                   ^
bomboane.cpp:57:13: error: 'w' was not declared in this scope
             w[m].s = pozmax;

             ^
bomboane.cpp:62:13: error: 'cout' was not declared in this scope
             cout << m << endl;

             ^
bomboane.cpp:64:25: error: 'w' was not declared in this scope
                 cout << w[i].s << " " << w[i].d << " " << w[i].b;

                         ^
bomboane.cpp:67:1: error: expected '}' at end of input
 }
 ^
bomboane.cpp:67:1: error: expected '}' at end of input

Cum funcționează evaluarea?

www.pbinfo.ro permite evaluarea a două tipuri de probleme:

  • probleme la care rezolvarea presupune scrierea unui program complet
  • probleme la care rezolvarea presupune scrierea unei secvențe de program - câteva instrucțiuni, o listă de declarații, una sau mai multe funcții, etc.

Problema Bomboane face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:

  • Programul sursă este compilat folosind compilatorul corespunzător. Dacă în urma compilării se obțin erori sau avertismente, acestea sunt afișate în această pagină.
  • Dacă programul a fost compilat, executabilul obținut va fi rulat, furnizându-i-se unul sau mai multe seturi de date de intrare, în concordanță cu restricțiile specifice problemei. Pentru fiecare set de date se obține un anumit punctaj, în raport cu corectitudinea soluției tale.

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ă.

Du-te sus!