import java.util.*;
import java.io.*;
public class triusis {
public static void main(String[] args) throws IOException{
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
StringTokenizer st = new StringTokenizer(r.readLine());
int n = Integer.parseInt(st.nextToken()); int m = Integer.parseInt(st.nextToken());
TreeMap<Long, Integer> multiset = new TreeMap<>();
for (int i = 0; i < n; i++) {
int x = Integer.parseInt(r.readLine());
long z = m * (i + 1) - x;
if(z < 0){
continue;
}
if(multiset.floorKey(z) == null){
multiset.put(z, 1);
}
else{
multiset.put(z, multiset.get(multiset.floorKey(z)) + 1);
}
}
int max = 0;
for(int e : multiset.values()){
max = Math.max(e, max);
}
pw.println(n - max);
pw.close();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
8328 KB |
Output is correct |
2 |
Correct |
49 ms |
8296 KB |
Output is correct |
3 |
Correct |
49 ms |
8376 KB |
Output is correct |
4 |
Correct |
50 ms |
8396 KB |
Output is correct |
5 |
Correct |
52 ms |
8256 KB |
Output is correct |
6 |
Correct |
50 ms |
8492 KB |
Output is correct |
7 |
Correct |
49 ms |
8376 KB |
Output is correct |
8 |
Correct |
49 ms |
8336 KB |
Output is correct |
9 |
Correct |
50 ms |
8252 KB |
Output is correct |
10 |
Correct |
50 ms |
8448 KB |
Output is correct |
11 |
Correct |
48 ms |
8228 KB |
Output is correct |
12 |
Correct |
50 ms |
8388 KB |
Output is correct |
13 |
Correct |
50 ms |
8220 KB |
Output is correct |
14 |
Correct |
50 ms |
8792 KB |
Output is correct |
15 |
Correct |
50 ms |
8440 KB |
Output is correct |
16 |
Correct |
50 ms |
8480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
8328 KB |
Output is correct |
2 |
Correct |
49 ms |
8296 KB |
Output is correct |
3 |
Correct |
49 ms |
8376 KB |
Output is correct |
4 |
Correct |
50 ms |
8396 KB |
Output is correct |
5 |
Correct |
52 ms |
8256 KB |
Output is correct |
6 |
Correct |
50 ms |
8492 KB |
Output is correct |
7 |
Correct |
49 ms |
8376 KB |
Output is correct |
8 |
Correct |
49 ms |
8336 KB |
Output is correct |
9 |
Correct |
50 ms |
8252 KB |
Output is correct |
10 |
Correct |
50 ms |
8448 KB |
Output is correct |
11 |
Correct |
48 ms |
8228 KB |
Output is correct |
12 |
Correct |
50 ms |
8388 KB |
Output is correct |
13 |
Correct |
50 ms |
8220 KB |
Output is correct |
14 |
Correct |
50 ms |
8792 KB |
Output is correct |
15 |
Correct |
50 ms |
8440 KB |
Output is correct |
16 |
Correct |
50 ms |
8480 KB |
Output is correct |
17 |
Correct |
49 ms |
8404 KB |
Output is correct |
18 |
Correct |
50 ms |
8504 KB |
Output is correct |
19 |
Correct |
53 ms |
8540 KB |
Output is correct |
20 |
Correct |
134 ms |
10960 KB |
Output is correct |
21 |
Correct |
110 ms |
10948 KB |
Output is correct |
22 |
Correct |
104 ms |
11784 KB |
Output is correct |
23 |
Correct |
141 ms |
12084 KB |
Output is correct |
24 |
Correct |
144 ms |
12176 KB |
Output is correct |
25 |
Incorrect |
141 ms |
12332 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
8404 KB |
Output is correct |
2 |
Correct |
50 ms |
8504 KB |
Output is correct |
3 |
Correct |
53 ms |
8540 KB |
Output is correct |
4 |
Correct |
134 ms |
10960 KB |
Output is correct |
5 |
Correct |
110 ms |
10948 KB |
Output is correct |
6 |
Correct |
104 ms |
11784 KB |
Output is correct |
7 |
Correct |
141 ms |
12084 KB |
Output is correct |
8 |
Correct |
144 ms |
12176 KB |
Output is correct |
9 |
Incorrect |
141 ms |
12332 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
8404 KB |
Output is correct |
2 |
Correct |
50 ms |
8504 KB |
Output is correct |
3 |
Correct |
53 ms |
8540 KB |
Output is correct |
4 |
Correct |
134 ms |
10960 KB |
Output is correct |
5 |
Correct |
110 ms |
10948 KB |
Output is correct |
6 |
Correct |
104 ms |
11784 KB |
Output is correct |
7 |
Correct |
141 ms |
12084 KB |
Output is correct |
8 |
Correct |
144 ms |
12176 KB |
Output is correct |
9 |
Incorrect |
141 ms |
12332 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |