Submission #685818

# Submission time Handle Problem Language Result Execution time Memory
685818 2023-01-25T01:44:14 Z bruhgamer A Huge Tower (CEOI10_tower) Java 11
30 / 100
1000 ms 56452 KB
//package USACO;
import java.util.*;
import java.io.*;
public class tower {
	public static void main(String[]args) throws IOException{
		Kattio io = new Kattio();
		int n = io.nextInt();
		int d = io.nextInt();
		int[]arr = new int[n];
		int[]valuesless = new int[n];
		for(int i = 0; i < n; i++) {
			arr[i] = io.nextInt();
		}
		Arrays.sort(arr);
		for(int i = 0; i < n; i++) {
			for(int j = i-1; j >= 0; j--) {
				if(arr[i] - arr[j] <= d) {
					valuesless[i]++;
				}
				else {
					break;
				}
			}
		}
		long[]values = new long[n];
		values[0] = 1;
		for(int i = 1; i < n ; i++) {
			values[i] = (values[i-1] * (valuesless[i] + 1)) % 1000000007L;
		}
		io.println(values[n-1]);
		io.close();
	}
	static 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(problemName + ".out");
			r = new BufferedReader(new FileReader(problemName + ".in"));
		}
		// 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()); }
	}
		
}
# Verdict Execution time Memory Grader output
1 Correct 57 ms 8644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 8504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 8488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 8600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 61 ms 8392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 66 ms 8256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 8348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 8112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 8416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 59 ms 8216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 8384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 62 ms 8416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 63 ms 8352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 8176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 96 ms 9436 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 255 ms 17056 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 338 ms 19680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 663 ms 24444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 835 ms 36264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1040 ms 56452 KB Time limit exceeded
2 Halted 0 ms 0 KB -