답안 #404586

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
404586 2021-05-14T17:07:52 Z TruaShamu Rabbit Carrot (LMIO19_triusis) Java 11
100 / 100
320 ms 23268 KB
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.ArrayList;

public class triusis {  // any other name breaks the grader lmao
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int N = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());

        ArrayList<Integer> unch = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int x = Integer.parseInt(br.readLine());
            if ((i + 1) * M >= x) {
                unch.add((i + 1) * M - x);
            }
        }
        System.out.println(N - NDS(unch));
    }

    private static int NDS(ArrayList<Integer> arr) {
        ArrayList<Integer> minEndings = new ArrayList<>();
        for (int i : arr) {
            int pos = bisectRight(minEndings, i);
            if (pos == minEndings.size()) {
                minEndings.add(i);
            } else {
                minEndings.set(pos, i);
            }
        }
        return minEndings.size();
    }

    private static int bisectRight(ArrayList<Integer> arr, int x) {
        int lo = 0;
        int hi = arr.size();
        while (lo < hi) {
            int mid = (lo + hi) / 2;
            if (x < arr.get(mid)) {
                hi = mid;
            } else {
                lo = mid + 1;
            }
        }
        return lo;
    }
}

/*
5 400
300
700
200
1000
500

 */
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 8404 KB Output is correct
2 Correct 77 ms 8212 KB Output is correct
3 Correct 81 ms 8220 KB Output is correct
4 Correct 70 ms 8304 KB Output is correct
5 Correct 73 ms 8112 KB Output is correct
6 Correct 73 ms 8120 KB Output is correct
7 Correct 79 ms 8244 KB Output is correct
8 Correct 70 ms 8436 KB Output is correct
9 Correct 70 ms 8236 KB Output is correct
10 Correct 70 ms 8192 KB Output is correct
11 Correct 71 ms 8336 KB Output is correct
12 Correct 74 ms 8404 KB Output is correct
13 Correct 72 ms 8332 KB Output is correct
14 Correct 69 ms 8312 KB Output is correct
15 Correct 69 ms 8316 KB Output is correct
16 Correct 72 ms 8292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 8404 KB Output is correct
2 Correct 77 ms 8212 KB Output is correct
3 Correct 81 ms 8220 KB Output is correct
4 Correct 70 ms 8304 KB Output is correct
5 Correct 73 ms 8112 KB Output is correct
6 Correct 73 ms 8120 KB Output is correct
7 Correct 79 ms 8244 KB Output is correct
8 Correct 70 ms 8436 KB Output is correct
9 Correct 70 ms 8236 KB Output is correct
10 Correct 70 ms 8192 KB Output is correct
11 Correct 71 ms 8336 KB Output is correct
12 Correct 74 ms 8404 KB Output is correct
13 Correct 72 ms 8332 KB Output is correct
14 Correct 69 ms 8312 KB Output is correct
15 Correct 69 ms 8316 KB Output is correct
16 Correct 72 ms 8292 KB Output is correct
17 Correct 69 ms 8276 KB Output is correct
18 Correct 69 ms 8416 KB Output is correct
19 Correct 70 ms 8384 KB Output is correct
20 Correct 111 ms 8652 KB Output is correct
21 Correct 158 ms 9788 KB Output is correct
22 Correct 187 ms 11644 KB Output is correct
23 Correct 199 ms 11940 KB Output is correct
24 Correct 199 ms 12016 KB Output is correct
25 Correct 184 ms 11756 KB Output is correct
26 Correct 213 ms 12004 KB Output is correct
27 Correct 180 ms 11640 KB Output is correct
28 Correct 191 ms 11828 KB Output is correct
29 Correct 175 ms 9888 KB Output is correct
30 Correct 196 ms 11868 KB Output is correct
31 Correct 194 ms 11928 KB Output is correct
32 Correct 187 ms 12104 KB Output is correct
33 Correct 213 ms 11716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 8276 KB Output is correct
2 Correct 69 ms 8416 KB Output is correct
3 Correct 70 ms 8384 KB Output is correct
4 Correct 111 ms 8652 KB Output is correct
5 Correct 158 ms 9788 KB Output is correct
6 Correct 187 ms 11644 KB Output is correct
7 Correct 199 ms 11940 KB Output is correct
8 Correct 199 ms 12016 KB Output is correct
9 Correct 184 ms 11756 KB Output is correct
10 Correct 213 ms 12004 KB Output is correct
11 Correct 180 ms 11640 KB Output is correct
12 Correct 191 ms 11828 KB Output is correct
13 Correct 175 ms 9888 KB Output is correct
14 Correct 196 ms 11868 KB Output is correct
15 Correct 194 ms 11928 KB Output is correct
16 Correct 187 ms 12104 KB Output is correct
17 Correct 213 ms 11716 KB Output is correct
18 Correct 71 ms 8404 KB Output is correct
19 Correct 77 ms 8212 KB Output is correct
20 Correct 81 ms 8220 KB Output is correct
21 Correct 70 ms 8304 KB Output is correct
22 Correct 73 ms 8112 KB Output is correct
23 Correct 73 ms 8120 KB Output is correct
24 Correct 79 ms 8244 KB Output is correct
25 Correct 70 ms 8436 KB Output is correct
26 Correct 70 ms 8236 KB Output is correct
27 Correct 70 ms 8192 KB Output is correct
28 Correct 71 ms 8336 KB Output is correct
29 Correct 74 ms 8404 KB Output is correct
30 Correct 72 ms 8332 KB Output is correct
31 Correct 69 ms 8312 KB Output is correct
32 Correct 69 ms 8316 KB Output is correct
33 Correct 72 ms 8292 KB Output is correct
34 Correct 166 ms 11612 KB Output is correct
35 Correct 161 ms 11676 KB Output is correct
36 Correct 162 ms 11848 KB Output is correct
37 Correct 186 ms 11792 KB Output is correct
38 Correct 185 ms 11528 KB Output is correct
39 Correct 205 ms 11584 KB Output is correct
40 Correct 194 ms 11832 KB Output is correct
41 Correct 159 ms 11696 KB Output is correct
42 Correct 189 ms 11716 KB Output is correct
43 Correct 189 ms 12080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 166 ms 11612 KB Output is correct
2 Correct 161 ms 11676 KB Output is correct
3 Correct 162 ms 11848 KB Output is correct
4 Correct 186 ms 11792 KB Output is correct
5 Correct 185 ms 11528 KB Output is correct
6 Correct 205 ms 11584 KB Output is correct
7 Correct 194 ms 11832 KB Output is correct
8 Correct 159 ms 11696 KB Output is correct
9 Correct 189 ms 11716 KB Output is correct
10 Correct 189 ms 12080 KB Output is correct
11 Correct 69 ms 8276 KB Output is correct
12 Correct 69 ms 8416 KB Output is correct
13 Correct 70 ms 8384 KB Output is correct
14 Correct 111 ms 8652 KB Output is correct
15 Correct 158 ms 9788 KB Output is correct
16 Correct 187 ms 11644 KB Output is correct
17 Correct 199 ms 11940 KB Output is correct
18 Correct 199 ms 12016 KB Output is correct
19 Correct 184 ms 11756 KB Output is correct
20 Correct 213 ms 12004 KB Output is correct
21 Correct 180 ms 11640 KB Output is correct
22 Correct 191 ms 11828 KB Output is correct
23 Correct 175 ms 9888 KB Output is correct
24 Correct 196 ms 11868 KB Output is correct
25 Correct 194 ms 11928 KB Output is correct
26 Correct 187 ms 12104 KB Output is correct
27 Correct 213 ms 11716 KB Output is correct
28 Correct 71 ms 8404 KB Output is correct
29 Correct 77 ms 8212 KB Output is correct
30 Correct 81 ms 8220 KB Output is correct
31 Correct 70 ms 8304 KB Output is correct
32 Correct 73 ms 8112 KB Output is correct
33 Correct 73 ms 8120 KB Output is correct
34 Correct 79 ms 8244 KB Output is correct
35 Correct 70 ms 8436 KB Output is correct
36 Correct 70 ms 8236 KB Output is correct
37 Correct 70 ms 8192 KB Output is correct
38 Correct 71 ms 8336 KB Output is correct
39 Correct 74 ms 8404 KB Output is correct
40 Correct 72 ms 8332 KB Output is correct
41 Correct 69 ms 8312 KB Output is correct
42 Correct 69 ms 8316 KB Output is correct
43 Correct 72 ms 8292 KB Output is correct
44 Correct 300 ms 22868 KB Output is correct
45 Correct 224 ms 15668 KB Output is correct
46 Correct 272 ms 17808 KB Output is correct
47 Correct 278 ms 18112 KB Output is correct
48 Correct 308 ms 22784 KB Output is correct
49 Correct 307 ms 23268 KB Output is correct
50 Correct 306 ms 17588 KB Output is correct
51 Correct 264 ms 18612 KB Output is correct
52 Correct 320 ms 19316 KB Output is correct
53 Correct 221 ms 15008 KB Output is correct
54 Correct 305 ms 22972 KB Output is correct
55 Correct 303 ms 22604 KB Output is correct