CSES - HIIT Open 2017 - Results
Submission details
Task:Jonnesort
Sender:IOG
Submission time:2017-05-27 12:24:43 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.05 sdetails
#2ACCEPTED0.07 sdetails
#3ACCEPTED0.04 sdetails
#4ACCEPTED0.06 sdetails
#5ACCEPTED0.05 sdetails
#60.06 sdetails
#7ACCEPTED0.05 sdetails
#8ACCEPTED0.06 sdetails
#9ACCEPTED0.02 sdetails
#100.04 sdetails
#11ACCEPTED0.04 sdetails
#120.05 sdetails
#130.04 sdetails
#14ACCEPTED0.03 sdetails
#15ACCEPTED0.04 sdetails
#160.06 sdetails
#17ACCEPTED0.03 sdetails
#18ACCEPTED0.04 sdetails
#19ACCEPTED0.05 sdetails
#20ACCEPTED0.04 sdetails
#21ACCEPTED0.04 sdetails
#220.06 sdetails
#230.06 sdetails
#24ACCEPTED0.04 sdetails
#25ACCEPTED0.06 sdetails
#26ACCEPTED0.05 sdetails
#27ACCEPTED0.07 sdetails
#28ACCEPTED0.04 sdetails
#29ACCEPTED0.05 sdetails
#30ACCEPTED0.04 sdetails
#31ACCEPTED0.05 sdetails
#32ACCEPTED0.04 sdetails

Code

#include <bits/stdc++.h>

using namespace std;

int main(void)
{
 cin.sync_with_stdio(0);
 cin.tie(0);
 int n = 0, k = 0;
 cin >> n >> k;
 vector<long> arr(n);
 for (int i = 0; i < n; i++)
 {
        cin >> arr[i];
 }
 vector<long> arr2(arr);
 sort(arr2.begin(), arr2.end());
 
 int maxdist = -1;
 
 for (unsigned int i = 0; i < arr.size(); ++i)
 {
     auto ptr = lower_bound(arr2.begin(), arr2.end(), arr[i]);
     
     //if (ptr)
     {
         int idx = ptr - arr2.begin();
         
         //cout << "arr[i] " << arr[i] << "\n";
         //cout << "idx " << idx << "\n";
         
         int dist = abs(idx - (int)i);
         
         //cout << "dist " << dist << "\n";
         
         if (dist > maxdist)
            maxdist = dist;
         
         //cout << "maxd " << maxdist << "\n\n";
     }
 
     
 }
 
 // cout << "maxd " << maxdist << "\n";
 
 float resf = (float) maxdist / (float) (k-1);
 int res = ceil(resf) + 1;
 
 cout << res << endl;
     
}

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:

input
5 2
996284497 350656747 457308991 ...

correct output
4

user output
5

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:

input
5 2
529605954 923422474 201326756 ...

correct output
3

user output
4

Test 11

Verdict: ACCEPTED

input
5 3
576266534 744033388 496724405 ...

correct output
3

user output
3

Test 12

Verdict:

input
5 4
834071670 478505412 812083191 ...

correct output
2

user output
3

Test 13

Verdict:

input
10 2
267520652 809884594 337238252 ...

correct output
6

user output
9

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:

input
10 9
962346225 344164325 546383748 ...

correct output
2

user output
3

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:

input
10 4
818177078 80429597 70171159 43...

correct output
3

user output
4

Test 23

Verdict:

input
1000 2
892940198 569293722 587284851 ...

correct output
924

user output
949

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