50642023-04-13 12:19:34czitaKövetkező permutáció (50 pont)cpp17Runtime error 3/507ms4568 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
base3/50
1Accepted0/03ms1808 KiB
2Runtime error0/04ms2188 KiB
3Wrong answer0/13ms2216 KiB
4Wrong answer0/12ms2428 KiB
5Wrong answer0/12ms2536 KiB
6Accepted1/13ms2756 KiB
7Wrong answer0/22ms2848 KiB
8Wrong answer0/22ms2844 KiB
9Wrong answer0/23ms3084 KiB
10Wrong answer0/22ms3088 KiB
11Wrong answer0/12ms3092 KiB
12Wrong answer0/13ms3208 KiB
13Wrong answer0/13ms3300 KiB
14Wrong answer0/13ms3372 KiB
15Wrong answer0/33ms3460 KiB
16Wrong answer0/33ms3572 KiB
17Runtime error0/33ms3564 KiB
18Runtime error0/34ms3820 KiB
19Runtime error0/34ms3924 KiB
20Runtime error0/36ms4064 KiB
21Runtime error0/36ms4292 KiB
22Runtime error0/37ms4112 KiB
23Runtime error0/37ms4244 KiB
24Runtime error0/37ms4240 KiB
25Runtime error0/26ms4568 KiB
26Accepted2/26ms4472 KiB