#2443
cb2
Se consideră un șir de numere naturale nenule a[1]
, a[2]
, …, a[n]
. Asupra șirului se efectuează Q
interogări. Fiecare interogare este dată de o pereche (x, s)
: care este indicele maxim p
cu proprietatea că a[i] ≤ x
, pentru orice i=1..p
și în plus a[1] + a[2] + ... + a[p] <= s
?
Trebuie să răspundeți la fiecare din cele Q
întrebări.
Problema | cb2 | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.5 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #53297036 | Utilizator | |
Fișier | cb2.cpp | Dimensiune | 385 B |
Data încărcării | 23 Octombrie 2024, 18:07 | Scor / rezultat | Eroare de compilare |
cb2.cpp: In function 'int main()': cb2.cpp:11:21: error: no matching function for call to 'max(long long int&, int&)' b[i]=max(a[i],b[i-1]); ^ cb2.cpp:11:21: note: candidates are: In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from cb2.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template argument deduction/substitution failed: cb2.cpp:11:21: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') b[i]=max(a[i],b[i-1]); ^ In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from cb2.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template argument deduction/substitution failed: cb2.cpp:11:21: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') b[i]=max(a[i],b[i-1]); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from cb2.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:4231:5: note: template<class _Tp> _Tp std::max(std::initializer_list<_Tp>) max(initializer_list<_Tp> __l) ^ /usr/include/c++/4.8/bits/stl_algo.h:4231:5: note: template argument deduction/substitution failed: cb2.cpp:11:21: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' b[i]=max(a[i],b[i-1]); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from cb2.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:4236:5: note: template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare) max(initializer_list<_Tp> __l, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algo.h:4236:5: note: template argument deduction/substitution failed: cb2.cpp:11:21: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' b[i]=max(a[i],b[i-1]); ^ cb2.cpp:17:36: error: invalid operands of types 'int' and 'int [100003]' to binary 'operator-' cout<<min(upper_bound(b[0],b[n],x)-b,upper_bound(a[0],a[n],s)-a)-1<<'\n'; ^ cb2.cpp:17:63: error: invalid operands of types 'long long int' and 'long long int [100003]' to binary 'operator-' cout<<min(upper_bound(b[0],b[n],x)-b,upper_bound(a[0],a[n],s)-a)-1<<'\n'; ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from cb2.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h: In instantiation of '_FIter std::upper_bound(_FIter, _FIter, const _Tp&) [with _FIter = int; _Tp = long long int]': cb2.cpp:17:34: required from here /usr/include/c++/4.8/bits/stl_algo.h:2476:2: error: no type named 'value_type' in 'struct std::iterator_traits<int>' _ValueType; ^ /usr/include/c++/4.8/bits/stl_algo.h:2478:2: error: no type named 'difference_type' in 'struct std::iterator_traits<int>' _DistanceType; ^ /usr/include/c++/4.8/bits/stl_algo.h:2492:16: error: invalid type argument of unary '*' (have 'int') if (__val < *__middle) ^ /usr/include/c++/4.8/bits/stl_algo.h: In instantiation of '_FIter std::upper_bound(_FIter, _FIter, const _Tp&) [with _FIter = long long int; _Tp = long long int]': cb2.cpp:17:61: required from here /usr/include/c++/4.8/bits/stl_algo.h:2476:2: error: no type named 'value_type' in 'struct std::iterator_traits<long long int>' _ValueType; ^ /usr/include/c++/4.8/bits/stl_algo.h:2478:2: error: no type named 'difference_type' in 'struct std::iterator_traits<long long int>' _DistanceType; ^ /usr/include/c++/4.8/bits/stl_algo.h:2492:16: error: invalid type argument of unary '*' (have 'long long int') if (__val < *__middle) ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema cb2 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ă.