CSES - HIIT Open 2017 - Results
Submission details
Task:Jonnesort
Sender:IOG
Submission time:2017-05-27 12:18:26 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#20.04 sdetails
#3ACCEPTED0.04 sdetails
#4ACCEPTED0.06 sdetails
#5ACCEPTED0.06 sdetails
#60.06 sdetails
#7ACCEPTED0.05 sdetails
#80.04 sdetails
#9ACCEPTED0.04 sdetails
#10ACCEPTED0.04 sdetails
#110.04 sdetails
#12ACCEPTED0.04 sdetails
#130.04 sdetails
#14ACCEPTED0.07 sdetails
#15ACCEPTED0.04 sdetails
#16ACCEPTED0.05 sdetails
#17ACCEPTED0.04 sdetails
#18ACCEPTED0.05 sdetails
#19ACCEPTED0.05 sdetails
#20ACCEPTED0.03 sdetails
#210.04 sdetails
#22ACCEPTED0.03 sdetails
#230.04 sdetails
#24ACCEPTED0.05 sdetails
#25ACCEPTED0.03 sdetails
#26ACCEPTED0.03 sdetails
#27ACCEPTED0.05 sdetails
#28ACCEPTED0.04 sdetails
#29ACCEPTED0.04 sdetails
#30ACCEPTED0.07 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();
         
         //out << "arr[i] " << arr[i] << "\n";
         //cout << "idx " << idx << "\n";
         
         int dist = abs(idx - (int)i);
         
         //cout << "dist " << dist << "\n\n";
         
         if (dist > maxdist)
            maxdist = dist;
     }
 
     
 }
 
 // cout << "maxd " << maxdist << "\n";
 
 float resf = (float) maxdist / (float) k;
 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:

input
5 2
793236043 906468936 436307784 ...

correct output
5

user output
3

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
3

Test 7

Verdict: ACCEPTED

input
5 3
425650400 627649597 507579568 ...

correct output
3

user output
3

Test 8

Verdict:

input
5 4
220321392 396059465 984419076 ...

correct output
3

user output
2

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:

input
5 3
576266534 744033388 496724405 ...

correct output
3

user output
2

Test 12

Verdict: ACCEPTED

input
5 4
834071670 478505412 812083191 ...

correct output
2

user output
2

Test 13

Verdict:

input
10 2
267520652 809884594 337238252 ...

correct output
6

user output
5

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:

input
10 3
751769346 268818221 967321245 ...

correct output
5

user output
4

Test 22

Verdict: ACCEPTED

input
10 4
818177078 80429597 70171159 43...

correct output
3

user output
3

Test 23

Verdict:

input
1000 2
892940198 569293722 587284851 ...

correct output
924

user output
475

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