이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |