50632023-04-13 12:18:45czitaKövetkező permutáció (50 pont)cpp17Wrong answer 3/507ms4024 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
1Accepted0/03ms1816 KiB
2Wrong answer0/04ms2156 KiB
3Wrong answer0/13ms2060 KiB
4Wrong answer0/13ms2164 KiB
5Wrong answer0/12ms2228 KiB
6Accepted1/12ms2228 KiB
7Wrong answer0/23ms2368 KiB
8Wrong answer0/23ms2540 KiB
9Wrong answer0/22ms2648 KiB
10Wrong answer0/23ms2860 KiB
11Wrong answer0/13ms2828 KiB
12Wrong answer0/13ms2956 KiB
13Wrong answer0/12ms3040 KiB
14Wrong answer0/13ms3172 KiB
15Wrong answer0/33ms3564 KiB
16Wrong answer0/33ms3512 KiB
17Wrong answer0/33ms3472 KiB
18Wrong answer0/33ms3476 KiB
19Wrong answer0/34ms3496 KiB
20Wrong answer0/36ms3500 KiB
21Wrong answer0/36ms3508 KiB
22Wrong answer0/37ms3632 KiB
23Wrong answer0/37ms3644 KiB
24Wrong answer0/37ms3856 KiB
25Wrong answer0/27ms4024 KiB
26Accepted2/26ms3784 KiB