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:31:52
2017-05-27 12:24:43
2017-05-27 12:18:26
2017-05-27 12:16:39
Task:Jonnesort
Sender:IOG
Submission time:2017-05-27 12:31:52
Language:C++
Status:READY
Result:ACCEPTED

Test results

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

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 = 999999;
 
 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 = idx - (int)i;
         
         //cout << "dist " << dist << "\n";
         
         if (dist < maxdist)
            maxdist = dist;
         
         //cout << "maxd " << maxdist << "\n\n";
     }
 
     
 }
 
 // cout << "maxd " << maxdist << "\n";
 
 float resf = (float) abs(maxdist) / (float) (k-1);
 int res = ceil(resf) + 1;
 
 cout << res << endl;
     
}

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