50622023-04-13 12:14:02czitaKövetkező permutáció (50 pont)cpp17Wrong answer 3/507ms4248 KiB


#include <bits/stdc++.h>
using namespace std;
int main()
{
      int n=6000;
    cin >> n; 
    vector<int> X(n, 0);
  
    for (size_t i = 0; i < n; i++)
    {
        cin >> X[i];
    }
    vector<int> Y;
    int db = n - 1;
    Y.push_back(X[n - 1]);
    while (db>0&&(X[db]<=X[db-1]))
    {
        Y.push_back(X[db]);
        db--;
    }
    int ut = X[db - 1];
    Y.push_back(X[db]);
    Y.push_back(X[db-1]);
    sort(Y.begin(),Y.end());
    int maxy = Y.capacity()-1;
    while (Y[maxy-1]>ut)
    {
        maxy--;
    }
    
    X[db - 1] = Y[maxy];
    for (int i = maxy-1; i >=0; i--)
    {
        if (db < X.capacity())
        {
            X[db] = Y[i];
            db++;
        }
    }
    for (int i = Y.capacity()-1; i > maxy; i--)
    {
        if (db < X.capacity())
        {
            X[db] = Y[i];
            db++;
        }
    }
    for (auto a : X)
    {
        cout << a<<" ";
    }
    cout << endl;
   
}
SubtaskSumTestVerdictTimeMemory
base3/50
1Wrong answer0/03ms1848 KiB
2Wrong answer0/04ms2172 KiB
3Wrong answer0/13ms2220 KiB
4Accepted1/13ms2440 KiB
5Wrong answer0/13ms2776 KiB
6Wrong answer0/12ms2940 KiB
7Wrong answer0/23ms2916 KiB
8Wrong answer0/22ms2992 KiB
9Wrong answer0/23ms3120 KiB
10Wrong answer0/22ms3132 KiB
11Wrong answer0/12ms3204 KiB
12Wrong answer0/13ms3328 KiB
13Wrong answer0/13ms3540 KiB
14Wrong answer0/13ms3756 KiB
15Wrong answer0/33ms3836 KiB
16Wrong answer0/33ms3840 KiB
17Wrong answer0/33ms3840 KiB
18Wrong answer0/33ms3840 KiB
19Wrong answer0/34ms4100 KiB
20Wrong answer0/36ms4012 KiB
21Wrong answer0/36ms4016 KiB
22Wrong answer0/36ms4020 KiB
23Wrong answer0/36ms4020 KiB
24Wrong answer0/36ms4020 KiB
25Wrong answer0/27ms4248 KiB
26Accepted2/27ms4232 KiB