제출 #1160222

#제출 시각아이디문제언어결과실행 시간메모리
1160222siegeonsticksRabbit Carrot (LMIO19_triusis)Java
컴파일 에러
0 ms0 KiB
import java.io.*; import java.util.*; public class RabbitCarrot { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); int m = Integer.parseInt(st.nextToken()); int[] heights = new int[n]; st = new StringTokenizer(br.readLine()); for (int i=0; i<n; i++) heights[i] = Integer.parseInt(st.nextToken()); int result = solve(heights, m); pw.println(result); pw.close(); br.close(); } private static int solve(int[] heights, int m) { int n = heights.length, currh = 0, c = 0; if (n==0) return 0; boolean[] modded = new boolean[n]; for (int i=0; i<n; i++) { if (heights[i]>currh+m) { modded[i] = true; currh = currh+m; } else currh = heights[i]; } for (boolean x:modded) if (x) c++; return c; } }

컴파일 시 표준 에러 (stderr) 메시지

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

=======