제출 #532735

#제출 시각아이디문제언어결과실행 시간메모리
532735Cubik65536A Huge Tower (CEOI10_tower)Java
컴파일 에러
0 ms0 KiB
import java.io.*; import java.util.*; public class tower { private static final int MOD = (int) 1e9 + 9; public static void main(String[] args) throws IOException { Kattio io = new Kattio(); int n = io.nextInt(); int d = io.nextInt(); int[] blocks = new int[n]; for (int i = 0; i < n; i++) { blocks[i] = io.nextInt(); } Arrays.sort(blocks); int result = 1; for (int i = 0, j = 0; i < n; i++) { while (j < n - 1 && blocks[j + 1] - blocks[i] <= d) { j++; } int dist = j - i + 1; result = (result * 1L * dist) % MOD; } io.println(result); io.close(); } } class Kattio extends PrintWriter { private BufferedReader r; private StringTokenizer st; // standard input public Kattio() { this(System.in, System.out); } public Kattio(InputStream i, OutputStream o) { super(o); r = new BufferedReader(new InputStreamReader(i)); } // USACO-style file input public Kattio(String problemName) throws IOException { super(new FileWriter(problemName + ".out")); r = new BufferedReader(new FileReader(problemName + ".in")); } // read next line public String readLine() { try { return r.readLine(); } catch (IOException e) { } return null; } // returns null if no more input public String next() { try { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(r.readLine()); return st.nextToken(); } catch (Exception e) { } return null; } public int nextInt() { return Integer.parseInt(next()); } public double nextDouble() { return Double.parseDouble(next()); } public long nextLong() { return Long.parseLong(next()); } }

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

tower.java:26: error: incompatible types: possible lossy conversion from long to int
            result = (result * 1L * dist) % MOD;
                                          ^
1 error