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 = 1; i <= n; i++) {
int x = Integer.parseInt(r.readLine());
long z = m * i - x;
if(z < 0){
continue;
}
if(multiset.higherKey(z) != null){
multiset.put(multiset.higherKey(z), multiset.get(multiset.higherKey(z)) - 1);
if(multiset.get(multiset.higherKey(z)) == 0){
multiset.remove(multiset.higherKey(z));
}
}
multiset.put(z, multiset.getOrDefault(z, 0) + 1);
}
int ans = 0;
for(int e : multiset.values()){
ans += e;
}
pw.println(n - ans);
pw.close();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
8636 KB |
Output is correct |
2 |
Correct |
51 ms |
8508 KB |
Output is correct |
3 |
Correct |
49 ms |
8488 KB |
Output is correct |
4 |
Correct |
49 ms |
8532 KB |
Output is correct |
5 |
Correct |
49 ms |
8608 KB |
Output is correct |
6 |
Correct |
53 ms |
8364 KB |
Output is correct |
7 |
Correct |
48 ms |
8308 KB |
Output is correct |
8 |
Correct |
49 ms |
8312 KB |
Output is correct |
9 |
Correct |
49 ms |
8580 KB |
Output is correct |
10 |
Correct |
49 ms |
8576 KB |
Output is correct |
11 |
Correct |
48 ms |
8324 KB |
Output is correct |
12 |
Correct |
51 ms |
8288 KB |
Output is correct |
13 |
Correct |
50 ms |
8428 KB |
Output is correct |
14 |
Correct |
59 ms |
8568 KB |
Output is correct |
15 |
Correct |
50 ms |
8580 KB |
Output is correct |
16 |
Correct |
56 ms |
8252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
8636 KB |
Output is correct |
2 |
Correct |
51 ms |
8508 KB |
Output is correct |
3 |
Correct |
49 ms |
8488 KB |
Output is correct |
4 |
Correct |
49 ms |
8532 KB |
Output is correct |
5 |
Correct |
49 ms |
8608 KB |
Output is correct |
6 |
Correct |
53 ms |
8364 KB |
Output is correct |
7 |
Correct |
48 ms |
8308 KB |
Output is correct |
8 |
Correct |
49 ms |
8312 KB |
Output is correct |
9 |
Correct |
49 ms |
8580 KB |
Output is correct |
10 |
Correct |
49 ms |
8576 KB |
Output is correct |
11 |
Correct |
48 ms |
8324 KB |
Output is correct |
12 |
Correct |
51 ms |
8288 KB |
Output is correct |
13 |
Correct |
50 ms |
8428 KB |
Output is correct |
14 |
Correct |
59 ms |
8568 KB |
Output is correct |
15 |
Correct |
50 ms |
8580 KB |
Output is correct |
16 |
Correct |
56 ms |
8252 KB |
Output is correct |
17 |
Correct |
53 ms |
8256 KB |
Output is correct |
18 |
Correct |
49 ms |
8364 KB |
Output is correct |
19 |
Correct |
49 ms |
8420 KB |
Output is correct |
20 |
Correct |
122 ms |
10900 KB |
Output is correct |
21 |
Correct |
110 ms |
10744 KB |
Output is correct |
22 |
Correct |
103 ms |
11632 KB |
Output is correct |
23 |
Correct |
137 ms |
12428 KB |
Output is correct |
24 |
Correct |
139 ms |
12632 KB |
Output is correct |
25 |
Correct |
137 ms |
12464 KB |
Output is correct |
26 |
Correct |
174 ms |
12552 KB |
Output is correct |
27 |
Correct |
126 ms |
11924 KB |
Output is correct |
28 |
Correct |
118 ms |
11744 KB |
Output is correct |
29 |
Correct |
109 ms |
10744 KB |
Output is correct |
30 |
Correct |
142 ms |
12476 KB |
Output is correct |
31 |
Correct |
177 ms |
12048 KB |
Output is correct |
32 |
Correct |
142 ms |
12536 KB |
Output is correct |
33 |
Correct |
142 ms |
12692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
8256 KB |
Output is correct |
2 |
Correct |
49 ms |
8364 KB |
Output is correct |
3 |
Correct |
49 ms |
8420 KB |
Output is correct |
4 |
Correct |
122 ms |
10900 KB |
Output is correct |
5 |
Correct |
110 ms |
10744 KB |
Output is correct |
6 |
Correct |
103 ms |
11632 KB |
Output is correct |
7 |
Correct |
137 ms |
12428 KB |
Output is correct |
8 |
Correct |
139 ms |
12632 KB |
Output is correct |
9 |
Correct |
137 ms |
12464 KB |
Output is correct |
10 |
Correct |
174 ms |
12552 KB |
Output is correct |
11 |
Correct |
126 ms |
11924 KB |
Output is correct |
12 |
Correct |
118 ms |
11744 KB |
Output is correct |
13 |
Correct |
109 ms |
10744 KB |
Output is correct |
14 |
Correct |
142 ms |
12476 KB |
Output is correct |
15 |
Correct |
177 ms |
12048 KB |
Output is correct |
16 |
Correct |
142 ms |
12536 KB |
Output is correct |
17 |
Correct |
142 ms |
12692 KB |
Output is correct |
18 |
Correct |
52 ms |
8636 KB |
Output is correct |
19 |
Correct |
51 ms |
8508 KB |
Output is correct |
20 |
Correct |
49 ms |
8488 KB |
Output is correct |
21 |
Correct |
49 ms |
8532 KB |
Output is correct |
22 |
Correct |
49 ms |
8608 KB |
Output is correct |
23 |
Correct |
53 ms |
8364 KB |
Output is correct |
24 |
Correct |
48 ms |
8308 KB |
Output is correct |
25 |
Correct |
49 ms |
8312 KB |
Output is correct |
26 |
Correct |
49 ms |
8580 KB |
Output is correct |
27 |
Correct |
49 ms |
8576 KB |
Output is correct |
28 |
Correct |
48 ms |
8324 KB |
Output is correct |
29 |
Correct |
51 ms |
8288 KB |
Output is correct |
30 |
Correct |
50 ms |
8428 KB |
Output is correct |
31 |
Correct |
59 ms |
8568 KB |
Output is correct |
32 |
Correct |
50 ms |
8580 KB |
Output is correct |
33 |
Correct |
56 ms |
8252 KB |
Output is correct |
34 |
Correct |
103 ms |
11876 KB |
Output is correct |
35 |
Correct |
108 ms |
11920 KB |
Output is correct |
36 |
Correct |
105 ms |
11972 KB |
Output is correct |
37 |
Correct |
143 ms |
12248 KB |
Output is correct |
38 |
Correct |
121 ms |
12088 KB |
Output is correct |
39 |
Correct |
118 ms |
12048 KB |
Output is correct |
40 |
Correct |
175 ms |
11924 KB |
Output is correct |
41 |
Correct |
103 ms |
11656 KB |
Output is correct |
42 |
Correct |
149 ms |
12500 KB |
Output is correct |
43 |
Correct |
165 ms |
12568 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
103 ms |
11876 KB |
Output is correct |
2 |
Correct |
108 ms |
11920 KB |
Output is correct |
3 |
Correct |
105 ms |
11972 KB |
Output is correct |
4 |
Correct |
143 ms |
12248 KB |
Output is correct |
5 |
Correct |
121 ms |
12088 KB |
Output is correct |
6 |
Correct |
118 ms |
12048 KB |
Output is correct |
7 |
Correct |
175 ms |
11924 KB |
Output is correct |
8 |
Correct |
103 ms |
11656 KB |
Output is correct |
9 |
Correct |
149 ms |
12500 KB |
Output is correct |
10 |
Correct |
165 ms |
12568 KB |
Output is correct |
11 |
Correct |
53 ms |
8256 KB |
Output is correct |
12 |
Correct |
49 ms |
8364 KB |
Output is correct |
13 |
Correct |
49 ms |
8420 KB |
Output is correct |
14 |
Correct |
122 ms |
10900 KB |
Output is correct |
15 |
Correct |
110 ms |
10744 KB |
Output is correct |
16 |
Correct |
103 ms |
11632 KB |
Output is correct |
17 |
Correct |
137 ms |
12428 KB |
Output is correct |
18 |
Correct |
139 ms |
12632 KB |
Output is correct |
19 |
Correct |
137 ms |
12464 KB |
Output is correct |
20 |
Correct |
174 ms |
12552 KB |
Output is correct |
21 |
Correct |
126 ms |
11924 KB |
Output is correct |
22 |
Correct |
118 ms |
11744 KB |
Output is correct |
23 |
Correct |
109 ms |
10744 KB |
Output is correct |
24 |
Correct |
142 ms |
12476 KB |
Output is correct |
25 |
Correct |
177 ms |
12048 KB |
Output is correct |
26 |
Correct |
142 ms |
12536 KB |
Output is correct |
27 |
Correct |
142 ms |
12692 KB |
Output is correct |
28 |
Correct |
52 ms |
8636 KB |
Output is correct |
29 |
Correct |
51 ms |
8508 KB |
Output is correct |
30 |
Correct |
49 ms |
8488 KB |
Output is correct |
31 |
Correct |
49 ms |
8532 KB |
Output is correct |
32 |
Correct |
49 ms |
8608 KB |
Output is correct |
33 |
Correct |
53 ms |
8364 KB |
Output is correct |
34 |
Correct |
48 ms |
8308 KB |
Output is correct |
35 |
Correct |
49 ms |
8312 KB |
Output is correct |
36 |
Correct |
49 ms |
8580 KB |
Output is correct |
37 |
Correct |
49 ms |
8576 KB |
Output is correct |
38 |
Correct |
48 ms |
8324 KB |
Output is correct |
39 |
Correct |
51 ms |
8288 KB |
Output is correct |
40 |
Correct |
50 ms |
8428 KB |
Output is correct |
41 |
Correct |
59 ms |
8568 KB |
Output is correct |
42 |
Correct |
50 ms |
8580 KB |
Output is correct |
43 |
Correct |
56 ms |
8252 KB |
Output is correct |
44 |
Correct |
314 ms |
28348 KB |
Output is correct |
45 |
Correct |
129 ms |
16076 KB |
Output is correct |
46 |
Correct |
285 ms |
17936 KB |
Output is correct |
47 |
Correct |
286 ms |
17756 KB |
Output is correct |
48 |
Correct |
311 ms |
27452 KB |
Output is correct |
49 |
Correct |
417 ms |
31364 KB |
Output is correct |
50 |
Correct |
227 ms |
17792 KB |
Output is correct |
51 |
Correct |
197 ms |
17896 KB |
Output is correct |
52 |
Correct |
373 ms |
25372 KB |
Output is correct |
53 |
Correct |
131 ms |
15136 KB |
Output is correct |
54 |
Correct |
313 ms |
27980 KB |
Output is correct |
55 |
Correct |
342 ms |
28104 KB |
Output is correct |