Submission #366244

# Submission time Handle Problem Language Result Execution time Memory
366244 2021-02-13T15:30:58 Z dapig Rabbit Carrot (LMIO19_triusis) Java 11
100 / 100
293 ms 17872 KB
//package lis;

import java.io.*;
import java.util.*;

class triusis {

	public static void main(String[] args) throws IOException {

		triusis obj = new triusis();

		obj.doStuff();

	}
	
	boolean check(int val, int m) {
		long v1 = nums[lis[m]];
		long v2 = nums[val];
		v2 -= (val-lis[m])*inc;
		return (v1 >= v2);
	}
	
	int bs(int val) {
		int l = 0, r = count;
		while (l < r) {
			int m = (l+r)/2;
			if (check(val, m)) {
				if (lis[m+1]==-1) return m;
				if (!check(val, m+1)) return m;
				l = m+1;
			} else r = m;
		}
		if (l==0) return (check(val, 0)) ? 0 : -1;
		return l;
	}
	
	int[] lis; int count = 0;
	void lis() {
		lis = new int[nums.length+1];
		Arrays.fill(lis, -1);
		lis[0] = 0;
		for (int i = 1; i < nums.length; i++) {
			int pos = bs(i)+1;
			if (pos==0) continue;
			if (pos > count) count = pos;
			lis[pos] = i;
		}
	}

	long[] nums;
	long inc;
	private void doStuff() throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		nums = new long[Integer.parseInt(st.nextToken())+1];
		inc = Integer.parseInt(st.nextToken());
		for (int i = 1; i < nums.length; i++) {
			nums[i] = Integer.parseInt(br.readLine());
		}
		br.close();
		
		lis();
		
		System.out.println(nums.length-1-count);

	}

}
# Verdict Execution time Memory Grader output
1 Correct 71 ms 8804 KB Output is correct
2 Correct 70 ms 8552 KB Output is correct
3 Correct 74 ms 8680 KB Output is correct
4 Correct 74 ms 8556 KB Output is correct
5 Correct 71 ms 8556 KB Output is correct
6 Correct 73 ms 8540 KB Output is correct
7 Correct 69 ms 8556 KB Output is correct
8 Correct 71 ms 8696 KB Output is correct
9 Correct 71 ms 8448 KB Output is correct
10 Correct 72 ms 8556 KB Output is correct
11 Correct 76 ms 8576 KB Output is correct
12 Correct 71 ms 8556 KB Output is correct
13 Correct 69 ms 8540 KB Output is correct
14 Correct 71 ms 8556 KB Output is correct
15 Correct 72 ms 8500 KB Output is correct
16 Correct 72 ms 8556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 8804 KB Output is correct
2 Correct 70 ms 8552 KB Output is correct
3 Correct 74 ms 8680 KB Output is correct
4 Correct 74 ms 8556 KB Output is correct
5 Correct 71 ms 8556 KB Output is correct
6 Correct 73 ms 8540 KB Output is correct
7 Correct 69 ms 8556 KB Output is correct
8 Correct 71 ms 8696 KB Output is correct
9 Correct 71 ms 8448 KB Output is correct
10 Correct 72 ms 8556 KB Output is correct
11 Correct 76 ms 8576 KB Output is correct
12 Correct 71 ms 8556 KB Output is correct
13 Correct 69 ms 8540 KB Output is correct
14 Correct 71 ms 8556 KB Output is correct
15 Correct 72 ms 8500 KB Output is correct
16 Correct 72 ms 8556 KB Output is correct
17 Correct 70 ms 8556 KB Output is correct
18 Correct 72 ms 8532 KB Output is correct
19 Correct 71 ms 8556 KB Output is correct
20 Correct 106 ms 9068 KB Output is correct
21 Correct 128 ms 10024 KB Output is correct
22 Correct 161 ms 12000 KB Output is correct
23 Correct 170 ms 12000 KB Output is correct
24 Correct 173 ms 11872 KB Output is correct
25 Correct 174 ms 11996 KB Output is correct
26 Correct 211 ms 12128 KB Output is correct
27 Correct 171 ms 12000 KB Output is correct
28 Correct 185 ms 12020 KB Output is correct
29 Correct 129 ms 9872 KB Output is correct
30 Correct 172 ms 11872 KB Output is correct
31 Correct 188 ms 12092 KB Output is correct
32 Correct 169 ms 11872 KB Output is correct
33 Correct 170 ms 12124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 8556 KB Output is correct
2 Correct 72 ms 8532 KB Output is correct
3 Correct 71 ms 8556 KB Output is correct
4 Correct 106 ms 9068 KB Output is correct
5 Correct 128 ms 10024 KB Output is correct
6 Correct 161 ms 12000 KB Output is correct
7 Correct 170 ms 12000 KB Output is correct
8 Correct 173 ms 11872 KB Output is correct
9 Correct 174 ms 11996 KB Output is correct
10 Correct 211 ms 12128 KB Output is correct
11 Correct 171 ms 12000 KB Output is correct
12 Correct 185 ms 12020 KB Output is correct
13 Correct 129 ms 9872 KB Output is correct
14 Correct 172 ms 11872 KB Output is correct
15 Correct 188 ms 12092 KB Output is correct
16 Correct 169 ms 11872 KB Output is correct
17 Correct 170 ms 12124 KB Output is correct
18 Correct 71 ms 8804 KB Output is correct
19 Correct 70 ms 8552 KB Output is correct
20 Correct 74 ms 8680 KB Output is correct
21 Correct 74 ms 8556 KB Output is correct
22 Correct 71 ms 8556 KB Output is correct
23 Correct 73 ms 8540 KB Output is correct
24 Correct 69 ms 8556 KB Output is correct
25 Correct 71 ms 8696 KB Output is correct
26 Correct 71 ms 8448 KB Output is correct
27 Correct 72 ms 8556 KB Output is correct
28 Correct 76 ms 8576 KB Output is correct
29 Correct 71 ms 8556 KB Output is correct
30 Correct 69 ms 8540 KB Output is correct
31 Correct 71 ms 8556 KB Output is correct
32 Correct 72 ms 8500 KB Output is correct
33 Correct 72 ms 8556 KB Output is correct
34 Correct 163 ms 12128 KB Output is correct
35 Correct 168 ms 12128 KB Output is correct
36 Correct 173 ms 12256 KB Output is correct
37 Correct 185 ms 11952 KB Output is correct
38 Correct 169 ms 12000 KB Output is correct
39 Correct 184 ms 12012 KB Output is correct
40 Correct 185 ms 12240 KB Output is correct
41 Correct 162 ms 11892 KB Output is correct
42 Correct 171 ms 12128 KB Output is correct
43 Correct 175 ms 12108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 163 ms 12128 KB Output is correct
2 Correct 168 ms 12128 KB Output is correct
3 Correct 173 ms 12256 KB Output is correct
4 Correct 185 ms 11952 KB Output is correct
5 Correct 169 ms 12000 KB Output is correct
6 Correct 184 ms 12012 KB Output is correct
7 Correct 185 ms 12240 KB Output is correct
8 Correct 162 ms 11892 KB Output is correct
9 Correct 171 ms 12128 KB Output is correct
10 Correct 175 ms 12108 KB Output is correct
11 Correct 70 ms 8556 KB Output is correct
12 Correct 72 ms 8532 KB Output is correct
13 Correct 71 ms 8556 KB Output is correct
14 Correct 106 ms 9068 KB Output is correct
15 Correct 128 ms 10024 KB Output is correct
16 Correct 161 ms 12000 KB Output is correct
17 Correct 170 ms 12000 KB Output is correct
18 Correct 173 ms 11872 KB Output is correct
19 Correct 174 ms 11996 KB Output is correct
20 Correct 211 ms 12128 KB Output is correct
21 Correct 171 ms 12000 KB Output is correct
22 Correct 185 ms 12020 KB Output is correct
23 Correct 129 ms 9872 KB Output is correct
24 Correct 172 ms 11872 KB Output is correct
25 Correct 188 ms 12092 KB Output is correct
26 Correct 169 ms 11872 KB Output is correct
27 Correct 170 ms 12124 KB Output is correct
28 Correct 71 ms 8804 KB Output is correct
29 Correct 70 ms 8552 KB Output is correct
30 Correct 74 ms 8680 KB Output is correct
31 Correct 74 ms 8556 KB Output is correct
32 Correct 71 ms 8556 KB Output is correct
33 Correct 73 ms 8540 KB Output is correct
34 Correct 69 ms 8556 KB Output is correct
35 Correct 71 ms 8696 KB Output is correct
36 Correct 71 ms 8448 KB Output is correct
37 Correct 72 ms 8556 KB Output is correct
38 Correct 76 ms 8576 KB Output is correct
39 Correct 71 ms 8556 KB Output is correct
40 Correct 69 ms 8540 KB Output is correct
41 Correct 71 ms 8556 KB Output is correct
42 Correct 72 ms 8500 KB Output is correct
43 Correct 72 ms 8556 KB Output is correct
44 Correct 230 ms 15988 KB Output is correct
45 Correct 225 ms 17524 KB Output is correct
46 Correct 242 ms 17632 KB Output is correct
47 Correct 241 ms 17628 KB Output is correct
48 Correct 239 ms 16488 KB Output is correct
49 Correct 246 ms 16624 KB Output is correct
50 Correct 293 ms 17872 KB Output is correct
51 Correct 259 ms 17632 KB Output is correct
52 Correct 260 ms 16528 KB Output is correct
53 Correct 218 ms 16832 KB Output is correct
54 Correct 240 ms 16992 KB Output is correct
55 Correct 245 ms 16736 KB Output is correct