시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 32 MB | 141 | 40 | 34 | 30.909% |
Everybody knows that Balázs has the fanciest fence in the whole town. It’s built up from N fancy sections. The sections are rectangles standing closely next to each other on the ground. The ith section has integer height hi and integer width wi.
We are looking for fancy rectangles on this fancy fence.
A rectangle is fancy if:
What is the number of fancy rectangles?
This number can be very big, so we are interested in it modulo 109 + 7.
The first line contains N, the number of sections.
The second line contains N space-separated integers, the ith number is hi.
The third line contains N space-separated integers, the ith number is wi.
You should print a single integer, the number of fancy rectangles modulo 109 + 7. So the output range is 0, 1, 2, . . . , 109 + 6.
번호 | 배점 | 제한 |
---|---|---|
1 | 12 | N ≤ 50 and hi ≤ 50 and wi = 1 for all i |
2 | 13 | hi = 1 or hi = 2 for all i |
3 | 15 | all hi are equal |
4 | 15 | hi ≤ hi+1 for all i ≤ N - 1 |
5 | 18 | N ≤ 1000 |
6 | 27 | No additional constraints |
2 1 2 1 2
12
There are 5 fancy rectangles of shape:
There are 3 fancy rectangles of shape:
There is 1 fancy rectangle of shape:
There are 2 fancy rectangles of shape:
There is 1 fancy rectangle of shape: