|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|4.5 초||1024 MB||13||12||12||92.308%|
Many containers are transported by ships to the JOI Port every day. They are transported to all over the country by trucks.
The JOI Port is very narrow. It has only two areas where we can put containers. In each area, we can put any number of containers vertically.
For safety reasons, when a container is transported by a ship, we have to put it on one of the areas. If some containers are already put there, we have to put it on the top of them. When we transport a container by a truck, we have to take a container from the top of the containers on one of the areas.
Today, N containers will be transported to the JOI Port. All of them will be transported by trucks.
Your task is to manage the facilities of the JOI Port. For each container, you know when it will come and when it will leave. Write a program which calculates the number of ways to put and take containers modulo 1 000 000 007.
Given the number of containers transported to the JOI Port and the time for each container to come and leave, write a program which calculates the number of ways to put and take containers satisfying the conditions modulo 1 000 000 007.
Read the following data from the standard input.
Write one line to the standard output. The output contains the number of ways to put and take containers satisfying the conditions modulo 1 000 000 007.
4 1 3 2 5 4 8 6 7
There are 4 ways to put and take containers. Denote the areas by A, B. The following ways to put containers satisfy the condition.
3 1 4 2 5 3 6
5 1 4 2 10 6 9 7 8 3 5
8 1 15 2 5 3 8 4 6 14 16 7 9 10 13 11 12