Logo
(追記) (追記ここまで)

19679번 - Fancy Fence 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 32 MB213595030.488%

문제

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:

  • its sides are either horizontal or vertical and have integer lengths
  • the distance between the rectangle and the ground is integer
  • the distance between the rectangle and the left side of the first section is integer
  • it’s lying completely on sections

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 ≤ N ≤ 105
  • 1 ≤ hi, wi ≤ 109

서브태스크

번호배점제한
112

N ≤ 50 and hi ≤ 50 and wi = 1 for all i

213

hi = 1 or hi = 2 for all i

315

all hi are equal

415

hihi+1 for all iN - 1

518

N ≤ 1000

627

No additional constraints

예제 입력 1

2
1 2
1 2

예제 출력 1

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:

출처

Olympiad > Central European Olympiad in Informatics > CEOI 2020 > Day 1 1번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /