Assigned Seating 2
Time limit1sMemory limit1024 MB
Count the ways to place each row's students in columns so that, within every column, height plus row offset strictly increases toward the back, modulo 10^9+7.
- Level
Medium6 of 10
- Topics
- Sorting, Combinatorics, Binary search
- Solved
- No attempts yet
Problem
This problem differs from 지정좌석 배치하기 1 only in its last paragraph and its output. Code that solves 지정좌석 배치하기 1 cannot solve this problem.
Professor Dalgu, a popular instructor at UDP University, has been assigned a lecture hall with a capacity of students. The seats form a rectangle of rows and columns. So that students in the back can follow the lecture, the seat height rises by for each row. Counting from the front, the rows are to , and the seat height of row is .
Professor Dalgu uses assigned seats for easy attendance checks, so each of the students sits in the same seat all semester. The professor surveyed which row each student wants and selected students for each row. Let be the heights of the students who want row .
No student's view may be blocked by a student in the same column in an earlier row. Specifically, the seat height plus the student's height must be greater than the seat height plus the height of every student in the same column in an earlier row.
Professor Dalgu wants to know how many ways there are to seat all students in their requested rows while meeting this condition. Find the count modulo .
Input
The first line contains , , and separated by spaces.
The next lines contain the heights of the students who want row , with line holding separated by spaces.
Output
Print the number of ways to seat all students in their requested rows that meet the condition, modulo .