Submission #1131168
Source Code Expand
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } static class TaskA { static final long MODULO = (long) (1e9 + 7); public void solve(int testNumber, InputReader in, PrintWriter out) { int n = in.nextInt(); int avail = 0; long res = 1; for (int i = 0; i < n; ++i) { int x = in.nextInt(); ++avail; while ((avail - 1) * 2 >= x) { res = res * avail % MODULO; --avail; } } while (avail > 0) { res = res * avail % MODULO; --avail; } out.println(res); } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } } }
Submission Info
Submission Time | |
---|---|
Task | A - Robot Racing |
User | Petr |
Language | Java8 (OpenJDK 1.8.0) |
Score | 900 |
Code Size | 2202 Byte |
Status | AC |
Exec Time | 194 ms |
Memory | 36468 KB |
Judge Result
Set Name | Sample | Subtask | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | 400 / 400 | ||||||
Status |
|
|
|
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 | 71 ms | 23380 KB |
0_01.txt | AC | 69 ms | 21460 KB |
0_02.txt | AC | 69 ms | 18516 KB |
0_03.txt | AC | 70 ms | 19028 KB |
1_00.txt | AC | 69 ms | 18772 KB |
1_01.txt | AC | 69 ms | 20308 KB |
1_02.txt | AC | 71 ms | 23376 KB |
1_03.txt | AC | 69 ms | 23252 KB |
1_04.txt | AC | 69 ms | 21204 KB |
1_05.txt | AC | 69 ms | 21460 KB |
1_06.txt | AC | 67 ms | 19540 KB |
1_07.txt | AC | 134 ms | 18004 KB |
1_08.txt | AC | 69 ms | 21460 KB |
1_09.txt | AC | 70 ms | 23636 KB |
1_10.txt | AC | 68 ms | 23380 KB |
2_00.txt | AC | 163 ms | 30608 KB |
2_01.txt | AC | 152 ms | 33764 KB |
2_02.txt | AC | 194 ms | 36468 KB |
2_03.txt | AC | 164 ms | 32676 KB |
2_04.txt | AC | 158 ms | 28432 KB |
2_05.txt | AC | 153 ms | 33636 KB |
2_06.txt | AC | 160 ms | 33712 KB |
2_07.txt | AC | 169 ms | 29684 KB |
2_08.txt | AC | 151 ms | 31796 KB |
2_09.txt | AC | 168 ms | 33908 KB |
2_10.txt | AC | 178 ms | 30236 KB |
2_11.txt | AC | 162 ms | 33944 KB |
2_12.txt | AC | 180 ms | 35856 KB |