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

17794번 - Automatic Accountant 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB73403451.515%

문제

The bank you work in has purchased an advanced technological solution to the problems it has with counting money deposited by clients. The machine works by running each individual coin along a sloped track. At every integer multiple of centimetres along, starting from 1cm, there is a slot in the track with a bucket underneath.

The slot will allow a coin to fall in, if the thickness of the coin (in millimetres) is less than or equal to the width of the slot (also in millimetres), and the mass of the coin (in grams) is greater than or equal to the trigger mass of the slot (also in grams).

Since the slots are spaced 1cm apart centre-to-centre, and since there can be a large number of coins (or other metal shapes) inserted, the amount of wear on the track will depend on total distance travelled by all coins.

Given a list of the coins that will be deposited, what total distance will they travel, in centimetres?

입력

The input consists of:

  • one line containing the number of slots, s (1 ≤ s ≤ 105).
  • s further lines, the ith line containing the width of a slot in millimetres and trigger mass in grams of the ith slot, ai and bi respectively (1 ≤ a, b ≤ 105).
  • one line containing the integer c (1 ≤ c ≤ 105), the number of coins.
  • c further lines, the jth line containing the thickness in millimetres and mass in grams of the jth coin, ui and vi respectively (1 ≤ u, v ≤ 105).

It is guaranteed that every coin will be able to fall into at least one slot.

출력

Output the total distance in centimetres travelled by coins.

제한

예제 입력 1

1
10 10
1
5 15

예제 출력 1

1

예제 입력 2

3
2 2
1 3
1 1
2
2 2
1 1

예제 출력 2

4

예제 입력 3

3
2 2
1 3
1 1
2
2 2
1 2

예제 출력 3

2

예제 입력 4

5
2 3
2 2
4 2
4 5
10 1
5
1 5
2 1
4 2
5 3
5 5

예제 출력 4

19

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > The UK & Ireland Programming Contest > UKIEPC 2019 A번

  • 문제를 만든 사람: Robin Lee
(追記) (追記ここまで)

출처

대학교 대회

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

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