Submission #1131176
Source Code Expand
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Egor Kulikov (egor@egork.net) */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } static class TaskA { public void solve(int testNumber, InputReader in, OutputWriter out) { int n = in.readInt(); int[] x = IOUtils.readIntArray(in, n); int[] canGo = new int[n]; for (int i = 1; i < n; i++) { canGo[i] = canGo[i - 1]; canGo[i] = Math.max(canGo[i], i - (x[i - 1] + 1) / 2); } int[] qty = new int[n]; for (int i : canGo) { qty[i]++; } long answer = 1; int has = 0; for (int i = 0; i < n; i++) { has += qty[i]; answer *= has; answer %= MiscUtils.MOD7; has--; } out.printLine(answer); } } static class IOUtils { public static int[] readIntArray(InputReader in, int size) { int[] array = new int[size]; for (int i = 0; i < size; i++) { array[i] = in.readInt(); } return array; } } static class MiscUtils { public static final int MOD7 = (int) (1e9 + 7); } static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private InputReader.SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public int read() { if (numChars == -1) { throw new InputMismatchException(); } if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) { return -1; } } return buf[curChar++]; } public int readInt() { int c = read(); while (isSpaceChar(c)) { c = read(); } int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') { throw new InputMismatchException(); } res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public boolean isSpaceChar(int c) { if (filter != null) { return filter.isSpaceChar(c); } return isWhitespace(c); } public static boolean isWhitespace(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } static class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter(Writer writer) { this.writer = new PrintWriter(writer); } public void close() { writer.close(); } public void printLine(long i) { writer.println(i); } } }
Submission Info
Submission Time | |
---|---|
Task | A - Robot Racing |
User | Egor |
Language | Java8 (OpenJDK 1.8.0) |
Score | 900 |
Code Size | 4519 Byte |
Status | AC |
Exec Time | 99 ms |
Memory | 24020 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 | 21460 KB |
0_01.txt | AC | 68 ms | 21716 KB |
0_02.txt | AC | 69 ms | 18388 KB |
0_03.txt | AC | 67 ms | 19156 KB |
1_00.txt | AC | 69 ms | 18900 KB |
1_01.txt | AC | 70 ms | 18900 KB |
1_02.txt | AC | 77 ms | 21588 KB |
1_03.txt | AC | 69 ms | 17876 KB |
1_04.txt | AC | 68 ms | 21332 KB |
1_05.txt | AC | 69 ms | 17876 KB |
1_06.txt | AC | 70 ms | 20052 KB |
1_07.txt | AC | 70 ms | 19028 KB |
1_08.txt | AC | 70 ms | 18516 KB |
1_09.txt | AC | 68 ms | 21076 KB |
1_10.txt | AC | 69 ms | 17620 KB |
2_00.txt | AC | 95 ms | 21716 KB |
2_01.txt | AC | 94 ms | 22868 KB |
2_02.txt | AC | 99 ms | 24020 KB |
2_03.txt | AC | 96 ms | 23764 KB |
2_04.txt | AC | 94 ms | 18772 KB |
2_05.txt | AC | 96 ms | 20308 KB |
2_06.txt | AC | 96 ms | 23892 KB |
2_07.txt | AC | 95 ms | 23508 KB |
2_08.txt | AC | 95 ms | 23892 KB |
2_09.txt | AC | 94 ms | 21588 KB |
2_10.txt | AC | 94 ms | 21972 KB |
2_11.txt | AC | 95 ms | 20436 KB |
2_12.txt | AC | 98 ms | 22100 KB |