57322023-09-10 17:35:28kukkermanKövetkező permutáció (50 pont)cpp14Accepted 50/507ms5204 KiB
#include <iostream>
#include <vector>

std::vector<int> beolvas(std::istream &in) {
    size_t n;
    in >> n;

    std::vector<int> v(n);
    for (auto i = 0u; i < n; i++) {
        in >> v[i];
    }

    return v;
}

void feldolgoz(std::vector<int> v) {
    const size_t n = v.size();

    size_t i;
    for (i = n - 1; v[i] < v[i - 1]; i--) {}
    i--;

    size_t j;
    for (j = n - 1; v[j] < v[i]; j--) {}

    for (auto k = 0u; k < i; k++) {
        std::cout << v[k] << ' ';
    }

    std::cout << v[j] << ' ' << v[i] << ' ';

    for (auto k = j + 1; k < n; k++) {
        std::cout << v[k] << ' ';
    }

    for (auto k = j - 1; k > i; k--) {
        std::cout << v[k] << ' ';
    }

    std::cout << std::endl;
}

int main() {
    auto v = beolvas(std::cin);
    feldolgoz(std::move(v));

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms2088 KiB
2Accepted0/04ms2276 KiB
3Accepted1/13ms2372 KiB
4Accepted1/12ms2456 KiB
5Accepted1/13ms2656 KiB
6Accepted1/13ms2756 KiB
7Accepted2/23ms3000 KiB
8Accepted2/22ms3156 KiB
9Accepted2/22ms3404 KiB
10Accepted2/22ms3592 KiB
11Accepted1/12ms3676 KiB
12Accepted1/12ms3652 KiB
13Accepted1/12ms3692 KiB
14Accepted1/13ms3940 KiB
15Accepted3/32ms4020 KiB
16Accepted3/33ms4024 KiB
17Accepted3/33ms4032 KiB
18Accepted3/33ms4304 KiB
19Accepted3/34ms4272 KiB
20Accepted3/36ms4316 KiB
21Accepted3/36ms4404 KiB
22Accepted3/37ms4468 KiB
23Accepted3/37ms4504 KiB
24Accepted3/36ms4572 KiB
25Accepted2/27ms4880 KiB
26Accepted2/27ms5204 KiB