Code Submission Evaluation System Login

CSES - HIIT Open 2017

HIIT Open 2017

Contest start:2017-05-27 11:00:00
Contest end:2017-05-27 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard


History
2017-05-27 13:00:47
Task:Jonnesort
Sender:kyy-kol
Submission time:2017-05-27 13:00:47
Status:READY
Result:ACCEPTED

Show test data

Code

#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int t[n];
    for (int i = 0; i < n; ++i) cin >> t[i];
    for (int r = 1; 1; r++) {
        int l = 0, f=0;
        for (int i = 0; i < n; ++i) {
            if (t[i] < l) {
                f = 1;
                break;
            }
            l = t[i];
        }
        if (!f) {
            cout << r << endl;
            break;
        }
        for (int i = 0; i+k <= n; ++i) {
            sort(t+i, t+i+k);
        }
    }
}