#511
KSort
Se dă un vector cu n
elemente, numere naturale și un număr k
. Ordonați crescător primele k
elemente ale vectorului și descrescător ultimele n-k
elemente.
Problema | KSort | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #34340865 | Utilizator | |
Fișier | ksort.cpp | Dimensiune | 326 B |
Data încărcării | 29 Ianuarie 2022, 20:05 | Scor / rezultat | Eroare de compilare |
ksort.cpp: In function 'int main()': ksort.cpp:8:13: error: cannot bind 'std::istream {aka std::basic_istream<char>}' lvalue to 'std::basic_istream<char>&&' cin>>a[i]; ^ In file included from /usr/include/c++/4.8/sstream:38:0, 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 ksort.cpp:1: /usr/include/c++/4.8/istream:872:5: error: initializing argument 1 of 'std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&&, _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = int [1001]]' operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) ^ In file included from /usr/include/c++/4.8/bits/stl_pair.h:59:0, from /usr/include/c++/4.8/bits/stl_algobase.h:64, 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/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 ksort.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h: In instantiation of 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = int (*)[1001]]': /usr/include/c++/4.8/bits/stl_algo.h:2211:62: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = int (*)[1001]]' /usr/include/c++/4.8/bits/stl_algo.h:5462:47: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = int (*)[1001]]' ksort.cpp:9:17: required from here /usr/include/c++/4.8/bits/stl_algo.h:2140:11: error: array must be initialized with a brace-enclosed initializer __val = _GLIBCXX_MOVE(*__i); ^ 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 ksort.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:2142:17: error: invalid array assignment *__first = _GLIBCXX_MOVE(__val); ^ In file included from /usr/include/c++/4.8/bits/stl_pair.h:59:0, from /usr/include/c++/4.8/bits/stl_algobase.h:64, 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/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 ksort.cpp:1: /usr/include/c++/4.8/bits/stl_heap.h: In instantiation of 'void std::make_heap(_RAIter, _RAIter) [with _RAIter = int (*)[1001]]': /usr/include/c++/4.8/bits/stl_algo.h:1933:39: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = int (*)[1001]]' /usr/include/c++/4.8/bits/stl_algo.h:5308:51: required from 'void std::partial_sort(_RAIter, _RAIter, _RAIter) [with _RAIter = int (*)[1001]]' /usr/include/c++/4.8/bits/stl_algo.h:2310:60: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = int (*)[1001]; _Size = int]' /usr/include/c++/4.8/bits/stl_algo.h:5461:36: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = int (*)[1001]]' ksort.cpp:9:17: required from here /usr/include/c++/4.8/bits/stl_heap.h:406:25: error: array must be initialized with a brace-enclosed initializer _ValueType __value = _GLIBCXX_MOVE(*(__first + __parent)); ^ /usr/include/c++/4.8/bits/stl_heap.h: In instantiation of 'void std::__pop_heap(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = int (*)[1001]]': /usr/include/c++/4.8/bits/stl_algo.h:1936:42: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = int (*)[1001]]' /usr/include/c++/4.8/bits/stl_algo.h:5308:51: required from 'void std::partial_sort(_RAIter, _RAIter, _RAIter) [with _RAIter = int (*)[1001]]' /usr/include/c++/4.8/bits/stl_algo.h:2310:60: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = int (*)[1001]; _Size = int]' /usr/include/c++/4.8/bits/stl_algo.h:5461:36: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = int (*)[1001]]' ksort.cpp:9:17: required from here /usr/include/c++/4.8/bits/stl_heap.h:261:28: error: array must be initialized with a brace-enclosed initializer _ValueType __value = _GLIBCXX_MOVE(*__result); ^ In file included from /usr/include/c++/4.8/bits/stl_algo.h:61:0, from /usr/include/c++/4.8/algorithm:62, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from ksort.cpp:1: /usr/include/c++/4.8/bits/stl_heap.h:262:17: error: invalid array assignment *__result = _GLIBCXX_MOVE(*__first); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema KSort 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ă.