This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//package week4;
import java.io.*;
import java.util.*;
class teams {
public static void main(String[] args) throws IOException {
teams obj = new teams();
obj.doStuff();
}
int[][] grid; // [pos] [number of valid ways if at cur pos and max val is #]
int[] vals;
private void doStuff() throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int len = Integer.parseInt(br.readLine());
StringTokenizer st = new StringTokenizer(br.readLine());
vals = new int[len];
for (int i = 0; i < vals.length; i++) {
vals[i] = Integer.parseInt(st.nextToken());
}
br.close();
grid = new int[vals.length][vals.length+1];
Arrays.fill(grid[grid.length-1], 1);
grid[grid.length-1][0] = 0;
for (int i = 1; i < grid[0].length; i++) {
grid[grid.length-1][i] += grid[grid.length-1][i-1];
}
for (int i = grid.length-2; i >= 0; i--) {
for (int j = 1; j <= i+1; j++) {
grid[i][j] = (grid[i+1][j+1]+grid[i][j-1])%1000007;
}
}
int ans = 1;
for (int i = 0; i < vals.length; i++) {
ans += grid[i][vals[i]-1];
ans %= 1000007;
}
System.out.println(ans);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |