50652023-04-13 12:25:09czitaKövetkező permutáció (50 pont)cpp11Wrong answer 0/507ms4688 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--)
    {
       
            X[db] = Y[i];
            db++;
       
    }
    for (int i = Y.capacity()-1; i > maxy; i--)
    {
        
            X[db] = Y[i];
            db++;
       
    }
    for (auto a : X)
    {
        cout << a<<" ";
    }
    cout << endl;
   
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/03ms1812 KiB
2Runtime error0/04ms2184 KiB
3Wrong answer0/12ms2128 KiB
4Wrong answer0/12ms2192 KiB
5Wrong answer0/12ms2320 KiB
6Wrong answer0/13ms2528 KiB
7Wrong answer0/22ms2620 KiB
8Wrong answer0/23ms2852 KiB
9Wrong answer0/23ms2948 KiB
10Wrong answer0/23ms3204 KiB
11Wrong answer0/13ms3416 KiB
12Wrong answer0/13ms3648 KiB
13Wrong answer0/12ms3668 KiB
14Wrong answer0/12ms3784 KiB
15Wrong answer0/32ms3792 KiB
16Wrong answer0/33ms3916 KiB
17Runtime error0/33ms4112 KiB
18Runtime error0/33ms4236 KiB
19Runtime error0/36ms4268 KiB
20Runtime error0/36ms4232 KiB
21Runtime error0/36ms4240 KiB
22Runtime error0/37ms4312 KiB
23Runtime error0/37ms4312 KiB
24Runtime error0/37ms4496 KiB
25Runtime error0/26ms4688 KiB
26Wrong answer0/27ms4348 KiB