Submission #1131275
Source Code Expand
import java.io.*; import java.util.*; public class Main { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; void solve() throws IOException { // out.println(123); // 1 - always // 2 - 1 >= 1 // 3 --> 1 >= 1, 2 >= 3 // 4 --> 1 >= 1, 2 >= 3, 3 >= 5 // second? // 1 - always // 2 - always // 3 - 2 >= 1 // 4 - 2 >= 1, 3 >= 3 // 5 - 2 >= 1, 3 >= 3, 4 >= 5 int n = nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = nextInt(); } int ret = 1; int cnt = 0; for (int i = 0; i < n; i++) { while (cnt <= i) { cnt++; } while (cnt < n && a[cnt - 1] >= 2 * (cnt - i) - 1) { cnt++; } ret = (int)((long)ret * (cnt - i) % P); } out.println(ret); } static final int P = 1_000_000_007; Main() throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); } public static void main(String[] args) throws IOException { new Main(); } String nextToken() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine()); } catch (Exception e) { eof = true; return null; } } return st.nextToken(); } String nextString() { try { return br.readLine(); } catch (IOException e) { eof = true; return null; } } int nextInt() throws IOException { return Integer.parseInt(nextToken()); } long nextLong() throws IOException { return Long.parseLong(nextToken()); } double nextDouble() throws IOException { return Double.parseDouble(nextToken()); } }
Submission Info
Submission Time | |
---|---|
Task | A - Robot Racing |
User | mmaxio |
Language | Java8 (OpenJDK 1.8.0) |
Score | 900 |
Code Size | 1717 Byte |
Status | AC |
Exec Time | 284 ms |
Memory | 37704 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 | 69 ms | 19284 KB |
0_01.txt | AC | 68 ms | 21076 KB |
0_02.txt | AC | 66 ms | 21204 KB |
0_03.txt | AC | 68 ms | 21076 KB |
1_00.txt | AC | 66 ms | 18772 KB |
1_01.txt | AC | 67 ms | 21076 KB |
1_02.txt | AC | 67 ms | 17876 KB |
1_03.txt | AC | 66 ms | 18388 KB |
1_04.txt | AC | 67 ms | 15700 KB |
1_05.txt | AC | 68 ms | 19924 KB |
1_06.txt | AC | 68 ms | 20948 KB |
1_07.txt | AC | 67 ms | 15700 KB |
1_08.txt | AC | 68 ms | 17748 KB |
1_09.txt | AC | 68 ms | 21204 KB |
1_10.txt | AC | 67 ms | 19284 KB |
2_00.txt | AC | 161 ms | 33648 KB |
2_01.txt | AC | 162 ms | 36772 KB |
2_02.txt | AC | 171 ms | 37704 KB |
2_03.txt | AC | 153 ms | 31516 KB |
2_04.txt | AC | 184 ms | 32036 KB |
2_05.txt | AC | 248 ms | 33796 KB |
2_06.txt | AC | 163 ms | 30340 KB |
2_07.txt | AC | 166 ms | 31076 KB |
2_08.txt | AC | 155 ms | 33900 KB |
2_09.txt | AC | 165 ms | 31480 KB |
2_10.txt | AC | 156 ms | 28784 KB |
2_11.txt | AC | 187 ms | 34032 KB |
2_12.txt | AC | 284 ms | 33632 KB |