Advertisement
Korotkodul

1H_v1

Sep 28th, 2023
1,185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.52 KB | None | 0 0
  1. #include <cmath>
  2. #include <ctime>
  3. #include <iostream>
  4. #include <vector>
  5.  
  6. using std::cin;
  7. using std::cout;
  8. using std::max;
  9. using std::min;
  10. using std::string;
  11. using std::vector;
  12. using std::swap;
  13.  
  14.  
  15. vector<int> srt5(vector<int> vv) {
  16.     for (int ii = 0; ii < 5; ++ii) {
  17.         for (int jj = 0; jj < 4; ++jj) {
  18.             if (vv[jj] > vv[jj + 1]) {
  19.                 swap(vv[jj], vv[jj + 1]);
  20.             }
  21.         }
  22.     }
  23.     return vv;
  24. }
  25.  
  26. vector<int> getB(vector<int> aa) {
  27.     vector<int> bb;
  28.     for (int ii = 0; ii < aa.size(); ++ii) {
  29.         vector <int> vv = {aa[ii], aa[ii + 1], aa[ii + 2], aa[ii + 3], aa[ii + 4]};
  30.         vv = srt5(vv);
  31.         bb.push_back(vv[2]);
  32.     }
  33.     return bb;
  34. }
  35.  
  36.  
  37.  
  38.  
  39. vector<int> Partition(vector<int> aa) {
  40.   int nn = aa.size();
  41.   if (nn <= 1) {
  42.     return aa;
  43.   }
  44.   int piv = DQS(aa);
  45.   vector<int> bb;
  46.   vector<int> cc;
  47.   for (int ii = 0; ii < nn; ++ii) {
  48.     if (aa[ii] >= piv) {
  49.       cc.push_back(aa[ii]);
  50.     } else {
  51.       bb.push_back(aa[ii]);
  52.     }
  53.   }
  54.   bb = F(bb);
  55.   cc = F(cc);
  56.   vector<int> dd;
  57.   for (int ii : bb) {
  58.     dd.push_back(ii);
  59.   }
  60.   for (int ii : cc) {
  61.     dd.push_back(ii);
  62.   }
  63.   return dd;
  64. }
  65.  
  66. int main() {
  67.   /*std::ios::sync_with_stdio(false);
  68.   std::cin.tie(0);
  69.   std::cout.tie(0);*/
  70.   int inf = 2e9;
  71.   int nn;
  72.   cin >> nn;
  73.   vector<int> aa(nn);
  74.   for (int& ii : aa) {
  75.     cin >> ii;
  76.   }
  77.   while (a.size() % 5 != 0) {
  78.     aa.push_back(inf);
  79.   }
  80.   aa = F(aa);
  81.   for (int ii : aa) {
  82.     cout << ii << ' ';
  83.   }
  84. }
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement