#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 |
![]() |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #44442529 | Utilizator | |
Fișier | ksort.cpp | Dimensiune | 563 B |
Data încărcării | 21 August 2023, 00:36 | Scor / rezultat | Eroare de compilare |
ksort.cpp: In function 'int main()': ksort.cpp:15:5: error: 'cin' was not declared in this scope cin >> n >> k; ^ ksort.cpp:15:5: note: suggested alternative: In file included from ksort.cpp:1:0: /usr/include/c++/4.8/iostream:60:18: note: 'std::cin' extern istream cin; /// Linked to standard input ^ ksort.cpp:17:5: error: 'vector' was not declared in this scope vector<int> vec(n); ^ ksort.cpp:17:5: note: suggested alternative: In file included from /usr/include/c++/4.8/vector:64:0, from ksort.cpp:2: /usr/include/c++/4.8/bits/stl_vector.h:210:11: note: 'std::vector' class vector : protected _Vector_base<_Tp, _Alloc> ^ ksort.cpp:17:12: error: expected primary-expression before 'int' vector<int> vec(n); ^ ksort.cpp:17:12: error: expected ';' before 'int' ksort.cpp:19:16: error: 'vec' was not declared in this scope cin >> vec[i]; ^ ksort.cpp:22:10: error: 'vec' was not declared in this scope sort(vec.begin(), vec.begin() + k, cmpin); ^ ksort.cpp:22:45: error: 'sort' was not declared in this scope sort(vec.begin(), vec.begin() + k, cmpin); ^ ksort.cpp:22:45: note: suggested alternative: In file included from /usr/include/c++/4.8/algorithm:62:0, from ksort.cpp:3: /usr/include/c++/4.8/bits/stl_algo.h:5483:5: note: 'std::sort' sort(_RandomAccessIterator __first, _RandomAccessIterator __last, ^ ksort.cpp:27:9: error: 'cout' was not declared in this scope cout << vec[i]; ^ ksort.cpp:27:9: note: suggested alternative: In file included from ksort.cpp:1:0: /usr/include/c++/4.8/iostream:61:18: note: 'std::cout' extern ostream cout; /// Linked to standard output ^
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ă.