This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
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();
}
}
# | 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... |