이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
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> map = new TreeMap<>();
for (int i = 1; i <= n; i++) {
int x = Integer.parseInt(r.readLine());
long z = m * i - x;
if(z < 0){
continue;
}
// pw.print(z + " ");
if(map.higherKey(z) == null){
if(map.size() == 0){
map.put(z, 1);
}
else{
map.put(z, map.get(map.lastKey()) + 1);
}
}
else{
int a = map.get(map.higherKey(z));
map.remove(map.higherKey(z));
map.put(z, a);
}
}
// System.out.println(map);
int max = 0;
for(int e : map.values()){
max = Math.max(e, max);
}
pw.println(n - max);
pw.close();
}
}
# | 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... |