Code Submission Evaluation System Login

HIIT Open 2017

Start:2017-05-27 11:00:00
End:2017-05-27 16:00:00
 

Tasks | Messages | Scoreboard | Statistics


CSES - HIIT Open 2017 - Results
History
2017-05-27 12:04:36
Task:Jonnesort
Sender:Kanadan virallinen maajoukkue
Submission time:2017-05-27 12:04:36
Language:C++
Status:READY
Result:ACCEPTED

Test results

testverdicttime (s)
#1ACCEPTED0.03 / 1.00details
#2ACCEPTED0.04 / 1.00details
#3ACCEPTED0.07 / 1.00details
#4ACCEPTED0.04 / 1.00details
#5ACCEPTED0.06 / 1.00details
#6ACCEPTED0.06 / 1.00details
#7ACCEPTED0.05 / 1.00details
#8ACCEPTED0.05 / 1.00details
#9ACCEPTED0.07 / 1.00details
#10ACCEPTED0.06 / 1.00details
#11ACCEPTED0.04 / 1.00details
#12ACCEPTED0.05 / 1.00details
#13ACCEPTED0.05 / 1.00details
#14ACCEPTED0.04 / 1.00details
#15ACCEPTED0.05 / 1.00details
#16ACCEPTED0.05 / 1.00details
#17ACCEPTED0.07 / 1.00details
#18ACCEPTED0.06 / 1.00details
#19ACCEPTED0.06 / 1.00details
#20ACCEPTED0.04 / 1.00details
#21ACCEPTED0.04 / 1.00details
#22ACCEPTED0.04 / 1.00details
#23ACCEPTED0.04 / 1.00details
#24ACCEPTED0.04 / 1.00details
#25ACCEPTED0.03 / 1.00details
#26ACCEPTED0.05 / 1.00details
#27ACCEPTED0.05 / 1.00details
#28ACCEPTED0.04 / 1.00details
#29ACCEPTED0.06 / 1.00details
#30ACCEPTED0.04 / 1.00details
#31ACCEPTED0.04 / 1.00details
#32ACCEPTED0.04 / 1.00details

Code

#include<iostream>
#include<queue>
#include<algorithm>

using namespace std;

bool sorted(int* arr, int k){
    for(int i=1; i<k; i++)
        if(arr[i-1]>arr[i])
            return false;
    return true;
}

int a[1000];
int main() {
    int n,k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
        cin>>a[i];
        
    int R=0;
    bool _=1;
    for(;_;){
        R++;
        bool cont=0;
        if(!sorted(a,k))
            cont=1;
        sort(a,a+k);
        
        for(int i=k; i<n; i++){
            for(int j=0; j<k-1; j++){
                if(a[i-j]<a[i-j-1]){
                    cont=1;
                    swap(a[i-j],a[i-j-1]);
                }
            }
        }
        
        if(!cont)
            break;
    }
    cout<<R<<endl;
    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
2 2
911338584 795590455
view   save

correct output
2
view   save

user output
2
view   save

Test 2

Verdict: ACCEPTED

input
5 2
793236043 906468936 436307784 ...
view   save

correct output
5
view   save

user output
5
view   save

Test 3

Verdict: ACCEPTED

input
5 3
175391 301978480 278080154 556...
view   save

correct output
2
view   save

user output
2
view   save

Test 4

Verdict: ACCEPTED

input
5 4
135097496 141787345 286485507 ...
view   save

correct output
2
view   save

user output
2
view   save

Test 5

Verdict: ACCEPTED

input
2 2
807833454 357319853
view   save

correct output
2
view   save

user output
2
view   save

Test 6

Verdict: ACCEPTED

input
5 2
996284497 350656747 457308991 ...
view   save

correct output
4
view   save

user output
4
view   save

Test 7

Verdict: ACCEPTED

input
5 3
425650400 627649597 507579568 ...
view   save

correct output
3
view   save

user output
3
view   save

Test 8

Verdict: ACCEPTED

input
5 4
220321392 396059465 984419076 ...
view   save

correct output
3
view   save

user output
3
view   save

Test 9

Verdict: ACCEPTED

input
2 2
154536640 992369170
view   save

correct output
1
view   save

user output
1
view   save

Test 10

Verdict: ACCEPTED

input
5 2
529605954 923422474 201326756 ...
view   save

correct output
3
view   save

user output
3
view   save

Test 11

Verdict: ACCEPTED

input
5 3
576266534 744033388 496724405 ...
view   save

correct output
3
view   save

user output
3
view   save

Test 12

Verdict: ACCEPTED

input
5 4
834071670 478505412 812083191 ...
view   save

correct output
2
view   save

user output
2
view   save

Test 13

Verdict: ACCEPTED

input
10 2
267520652 809884594 337238252 ...
view   save

correct output
6
view   save

user output
6
view   save

Test 14

Verdict: ACCEPTED

input
10 10
691659885 769645778 522400483 ...
view   save

correct output
2
view   save

user output
2
view   save

Test 15

Verdict: ACCEPTED

input
10 9
496062582 138374143 824827241 ...
view   save

correct output
2
view   save

user output
2
view   save

Test 16

Verdict: ACCEPTED

input
10 9
962346225 344164325 546383748 ...
view   save

correct output
2
view   save

user output
2
view   save

Test 17

Verdict: ACCEPTED

input
10 7
911172 834480158 332950221 217...
view   save

correct output
3
view   save

user output
3
view   save

Test 18

Verdict: ACCEPTED

input
10 5
637278906 758810300 799221426 ...
view   save

correct output
3
view   save

user output
3
view   save

Test 19

Verdict: ACCEPTED

input
10 8
613663177 241419820 897995174 ...
view   save

correct output
2
view   save

user output
2
view   save

Test 20

Verdict: ACCEPTED

input
10 9
301552142 105874609 117157673 ...
view   save

correct output
2
view   save

user output
2
view   save

Test 21

Verdict: ACCEPTED

input
10 3
751769346 268818221 967321245 ...
view   save

correct output
5
view   save

user output
5
view   save

Test 22

Verdict: ACCEPTED

input
10 4
818177078 80429597 70171159 43...
view   save

correct output
3
view   save

user output
3
view   save

Test 23

Verdict: ACCEPTED

input
1000 2
892940198 569293722 587284851 ...
view   save

correct output
924
view   save

user output
924
view   save

Test 24

Verdict: ACCEPTED

input
1000 1000
388348070 367903870 346031575 ...
view   save

correct output
2
view   save

user output
2
view   save

Test 25

Verdict: ACCEPTED

input
1000 478
940740782 714381689 937823318 ...
view   save

correct output
4
view   save

user output
4
view   save

Test 26

Verdict: ACCEPTED

input
1000 276
544213568 442831234 414847889 ...
view   save

correct output
5
view   save

user output
5
view   save

Test 27

Verdict: ACCEPTED

input
1000 223
429632666 21178061 489096976 3...
view   save

correct output
6
view   save

user output
6
view   save

Test 28

Verdict: ACCEPTED

input
1000 111
744098828 406171561 343811321 ...
view   save

correct output
10
view   save

user output
10
view   save

Test 29

Verdict: ACCEPTED

input
1000 103
670737224 725487311 939213258 ...
view   save

correct output
11
view   save

user output
11
view   save

Test 30

Verdict: ACCEPTED

input
1000 925
908985873 374431295 932008376 ...
view   save

correct output
3
view   save

user output
3
view   save

Test 31

Verdict: ACCEPTED

input
1000 267
624861176 273000858 900365752 ...
view   save

correct output
5
view   save

user output
5
view   save

Test 32

Verdict: ACCEPTED

input
1000 487
662518939 604995512 370723442 ...
view   save

correct output
3
view   save

user output
3
view   save