#3437
Într-o țară îndepărtată, economia este în criză. Cea mai mare problemă este lipsa de capital care creează blocaje financiare. De exemplu, o firmă X poate avea datorii către o firmă Y pe care nu le poate plăti, deoarece o altă firmă Z are datorii către firma X pe care nu le-a plătit, ş.a.m.d.
Există o listă cu toate datoriile firmelor sub forma următoare:
X > Y S
cu semnificaţia “firma X datorează firmei Y suma S”. Este posibil ca X să aibă mai multe datorii la firma Y (în funcţie de contractele derulate împreună) sau chiar ca X să aibă datorii la Y și Y să aibă datorii la X.
Cunoscând lista cu datoriile firmelor, scrieți un program care să rezolve următoarele cerințe:
SD SP, unde SD reprezintă suma totală a datoriilor pe care firma le are către alte firme, iar SP este totalul sumelor pe care firma trebuie să le primească de la alte firme.OJI 2020, clasa a VIII-a
| Problema | Datorii1 | Operații I/O |
datorii.in/datorii.out
|
|---|---|---|---|
| Limita timp | 0.5 secunde | Limita memorie |
Total: 16 MB
/
Stivă 8 MB
|
| Id soluție | #63613492 | Utilizator | |
| Fișier | datorii1.cpp | Dimensiune | 953 B |
| Data încărcării | 11 Martie 2026, 12:39 | Scor/rezultat | Eroare de compilare |
In file included from /usr/include/c++/4.8/map:61:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:80, from datorii1.cpp:1: /usr/include/c++/4.8/bits/stl_map.h: In instantiation of 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::basic_string<char>; _Tp = long long int; _Compare = long long int; _Alloc = std::allocator<std::pair<const std::basic_string<char>, long long int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = long long int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::basic_string<char>]': datorii1.cpp:36:16: required from here /usr/include/c++/4.8/bits/stl_map.h:463:31: error: expression cannot be used as a function if (__i == end() || key_comp()(__k, (*__i).first)) ^ In file included from /usr/include/c++/4.8/map:60:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:80, from datorii1.cpp:1: /usr/include/c++/4.8/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_lower_bound(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type, const _Key&) [with _Key = std::basic_string<char>; _Val = std::pair<const std::basic_string<char>, long long int>; _KeyOfValue = std::_Select1st<std::pair<const std::basic_string<char>, long long int> >; _Compare = long long int; _Alloc = std::allocator<std::pair<const std::basic_string<char>, long long int> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator<std::pair<const std::basic_string<char>, long long int> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const std::basic_string<char>, long long int> >*]': /usr/include/c++/4.8/bits/stl_tree.h:879:56: required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::lower_bound(const key_type&) [with _Key = std::basic_string<char>; _Val = std::pair<const std::basic_string<char>, long long int>; _KeyOfValue = std::_Select1st<std::pair<const std::basic_string<char>, long long int> >; _Compare = long long int; _Alloc = std::allocator<std::pair<const std::basic_string<char>, long long int> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator<std::pair<const std::basic_string<char>, long long int> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::key_type = std::basic_string<char>]' /usr/include/c++/4.8/bits/stl_map.h:864:36: required from 'std::map<_Key, _Tp, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare, _Alloc>::lower_bound(const key_type&) [with _Key = std::basic_string<char>; _Tp = long long int; _Compare = long long int; _Alloc = std::allocator<std::pair<const std::basic_string<char>, long long int> >; std::map<_Key, _Tp, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator<std::pair<const std::basic_string<char>, long long int> >; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::basic_string<char>]' /usr/include/c++/4.8/bits/stl_map.h:461:32: required from 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::basic_string<char>; _Tp = long long int; _Compare = long long int; _Alloc = std::allocator<std::pair<const std::basic_string<char>, long long int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = long long int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::basic_string<char>]' datorii1.cpp:36:16: required from here /usr/include/c++/4.8/bits/stl_tree.h:1141:6: error: expression cannot be used as a function if (!_M_impl._M_key_compare(_S_key(__x), __k)) ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Datorii1 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ă.