Submission #1131228


Source Code Expand

import java.io.*;
import java.util.*;

public class Main {
	FastScanner in;
	PrintWriter out;

	void solve() {
		final int mod = (int) 1e9 + 7;
		int n = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		long res = 1;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int pos = a[i];
			cnt++;
			int can = (pos + 1) / 2;
			while (cnt > can) {
				res = res * cnt % mod;
				cnt--;
			}
		}
		while (cnt > 1) {
			res = res * cnt % mod;
			cnt--;
		}
		out.println(res);
	}

	void run() {
		try {
			in = new FastScanner(new File("object.in"));
			out = new PrintWriter(new File("object.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new Main().runIO();
	}
}

Submission Info

Submission Time
Task A - Robot Racing
User qwerty787788
Language Java8 (OpenJDK 1.8.0)
Score 900
Code Size 2141 Byte
Status AC
Exec Time 349 ms
Memory 35860 KB

Judge Result

Set Name Sample Subtask All
Score / Max Score 0 / 0 500 / 500 400 / 400
Status
AC × 4
AC × 14
AC × 28
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
Subtask 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt
Case Name Status Exec Time Memory
0_00.txt AC 67 ms 18004 KB
0_01.txt AC 103 ms 19028 KB
0_02.txt AC 68 ms 19156 KB
0_03.txt AC 71 ms 21204 KB
1_00.txt AC 67 ms 18772 KB
1_01.txt AC 68 ms 19028 KB
1_02.txt AC 68 ms 21076 KB
1_03.txt AC 68 ms 19156 KB
1_04.txt AC 69 ms 15828 KB
1_05.txt AC 71 ms 23124 KB
1_06.txt AC 70 ms 18260 KB
1_07.txt AC 68 ms 19284 KB
1_08.txt AC 68 ms 18260 KB
1_09.txt AC 125 ms 21332 KB
1_10.txt AC 69 ms 21076 KB
2_00.txt AC 165 ms 30232 KB
2_01.txt AC 182 ms 30312 KB
2_02.txt AC 170 ms 35860 KB
2_03.txt AC 165 ms 33772 KB
2_04.txt AC 175 ms 34468 KB
2_05.txt AC 349 ms 31852 KB
2_06.txt AC 169 ms 31524 KB
2_07.txt AC 166 ms 33780 KB
2_08.txt AC 165 ms 33780 KB
2_09.txt AC 167 ms 31724 KB
2_10.txt AC 164 ms 34884 KB
2_11.txt AC 170 ms 32788 KB
2_12.txt AC 172 ms 34608 KB