CSES - HIIT Open 2017 - Results
Submission details
Task:Jonnesort
Sender:Game of Nolife
Submission time:2017-05-27 11:19:02 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#2ACCEPTED0.08 sdetails
#3ACCEPTED0.04 sdetails
#4ACCEPTED0.04 sdetails
#5ACCEPTED0.06 sdetails
#6ACCEPTED0.06 sdetails
#7ACCEPTED0.06 sdetails
#8ACCEPTED0.04 sdetails
#9ACCEPTED0.05 sdetails
#10ACCEPTED0.04 sdetails
#11ACCEPTED0.05 sdetails
#12ACCEPTED0.06 sdetails
#13ACCEPTED0.03 sdetails
#14ACCEPTED0.05 sdetails
#15ACCEPTED0.06 sdetails
#16ACCEPTED0.05 sdetails
#17ACCEPTED0.06 sdetails
#18ACCEPTED0.06 sdetails
#19ACCEPTED0.04 sdetails
#20ACCEPTED0.05 sdetails
#21ACCEPTED0.03 sdetails
#22ACCEPTED0.06 sdetails
#23ACCEPTED0.06 sdetails
#24ACCEPTED0.04 sdetails
#25ACCEPTED0.08 sdetails
#26ACCEPTED0.04 sdetails
#27ACCEPTED0.09 sdetails
#28ACCEPTED0.06 sdetails
#29ACCEPTED0.06 sdetails
#30ACCEPTED0.06 sdetails
#31ACCEPTED0.08 sdetails
#32ACCEPTED0.07 sdetails

Code

#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

ll xs [1010];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> xs[i];
	}
	int round = 0;
	while (1) {
		bool changed = false;
		for (int i = 0; i <= n - k; i++) {
			for (int j = 0; j < k - 1; j++) {
				if (xs[i + j] > xs[i + j + 1]) {
					changed = true;
				}
			}
			sort(xs + i, xs + i + k);
		}
		round++;
		if (!changed) {
			break;
		}
	}
	cout << round << "\n";
}

Test details

Test 1

Verdict: ACCEPTED

input
2 2
911338584 795590455

correct output
2

user output
2

Test 2

Verdict: ACCEPTED

input
5 2
793236043 906468936 436307784 ...

correct output
5

user output
5

Test 3

Verdict: ACCEPTED

input
5 3
175391 301978480 278080154 556...

correct output
2

user output
2

Test 4

Verdict: ACCEPTED

input
5 4
135097496 141787345 286485507 ...

correct output
2

user output
2

Test 5

Verdict: ACCEPTED

input
2 2
807833454 357319853

correct output
2

user output
2

Test 6

Verdict: ACCEPTED

input
5 2
996284497 350656747 457308991 ...

correct output
4

user output
4

Test 7

Verdict: ACCEPTED

input
5 3
425650400 627649597 507579568 ...

correct output
3

user output
3

Test 8

Verdict: ACCEPTED

input
5 4
220321392 396059465 984419076 ...

correct output
3

user output
3

Test 9

Verdict: ACCEPTED

input
2 2
154536640 992369170

correct output
1

user output
1

Test 10

Verdict: ACCEPTED

input
5 2
529605954 923422474 201326756 ...

correct output
3

user output
3

Test 11

Verdict: ACCEPTED

input
5 3
576266534 744033388 496724405 ...

correct output
3

user output
3

Test 12

Verdict: ACCEPTED

input
5 4
834071670 478505412 812083191 ...

correct output
2

user output
2

Test 13

Verdict: ACCEPTED

input
10 2
267520652 809884594 337238252 ...

correct output
6

user output
6

Test 14

Verdict: ACCEPTED

input
10 10
691659885 769645778 522400483 ...

correct output
2

user output
2

Test 15

Verdict: ACCEPTED

input
10 9
496062582 138374143 824827241 ...

correct output
2

user output
2

Test 16

Verdict: ACCEPTED

input
10 9
962346225 344164325 546383748 ...

correct output
2

user output
2

Test 17

Verdict: ACCEPTED

input
10 7
911172 834480158 332950221 217...

correct output
3

user output
3

Test 18

Verdict: ACCEPTED

input
10 5
637278906 758810300 799221426 ...

correct output
3

user output
3

Test 19

Verdict: ACCEPTED

input
10 8
613663177 241419820 897995174 ...

correct output
2

user output
2

Test 20

Verdict: ACCEPTED

input
10 9
301552142 105874609 117157673 ...

correct output
2

user output
2

Test 21

Verdict: ACCEPTED

input
10 3
751769346 268818221 967321245 ...

correct output
5

user output
5

Test 22

Verdict: ACCEPTED

input
10 4
818177078 80429597 70171159 43...

correct output
3

user output
3

Test 23

Verdict: ACCEPTED

input
1000 2
892940198 569293722 587284851 ...

correct output
924

user output
924

Test 24

Verdict: ACCEPTED

input
1000 1000
388348070 367903870 346031575 ...

correct output
2

user output
2

Test 25

Verdict: ACCEPTED

input
1000 478
940740782 714381689 937823318 ...

correct output
4

user output
4

Test 26

Verdict: ACCEPTED

input
1000 276
544213568 442831234 414847889 ...

correct output
5

user output
5

Test 27

Verdict: ACCEPTED

input
1000 223
429632666 21178061 489096976 3...

correct output
6

user output
6

Test 28

Verdict: ACCEPTED

input
1000 111
744098828 406171561 343811321 ...

correct output
10

user output
10

Test 29

Verdict: ACCEPTED

input
1000 103
670737224 725487311 939213258 ...

correct output
11

user output
11

Test 30

Verdict: ACCEPTED

input
1000 925
908985873 374431295 932008376 ...

correct output
3

user output
3

Test 31

Verdict: ACCEPTED

input
1000 267
624861176 273000858 900365752 ...

correct output
5

user output
5

Test 32

Verdict: ACCEPTED

input
1000 487
662518939 604995512 370723442 ...

correct output
3

user output
3