Submission #385221

#TimeUsernameProblemLanguageResultExecution timeMemory
385221SansPapyrus683Rabbit Carrot (LMIO19_triusis)Java
Compilation error
0 ms0 KiB
import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.ArrayList; public class Rabbit { public static void main(String[] args) throws IOException { BufferedReader read = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer inital = new StringTokenizer(read.readLine()); int poleNum = Integer.parseInt(inital.nextToken()); int jumpHeight = Integer.parseInt(inital.nextToken()); ArrayList<Integer> possUnchanged = new ArrayList<>(); for (int p = 0; p < poleNum; p++) { int pole = Integer.parseInt(read.readLine()); if ((p + 1) * jumpHeight >= pole) { possUnchanged.add((p + 1) * jumpHeight - pole); } } System.out.println(poleNum - longestNondecSubseq(possUnchanged)); } private static int longestNondecSubseq(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; } }

Compilation message (stderr)

triusis.java:7: error: class Rabbit is public, should be declared in a file named Rabbit.java
public class Rabbit {
       ^
1 error