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

28049번 - Joining a Marathon 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3.5 초 (추가 시간 없음) 1024 MB7212915.517%

문제

There are $R$ runners about to participate in a marathon. Johnny, who is organizing the marathon, knows that if a runner starts to run at time $T$ with constant speed $S,ドル then at time $t$ (for $t ≥ T$) the runner will be at position $(t - T) \times S$ on the track. Before time $T,ドル the runner is considered to not be on the track.

Of course, such an event has to have great photos taken. $P$ photos will be taken in total. Each photo will be taken at a specific time and will contain a carefully chosen segment of the track. If there are no runners in that segment at that time, the photo is considered to be trash.

Johnny, knowing all this, was saddened by the number of trash photos that would come from his event, so he decided to take the matter into his own feet and participate in the marathon along with the other runners.

Johnny is considering how he may run, so he will ask you $Q$ queries of the following format: if Johnny starts to run at a given time with a certain constant speed, how many trash photos will still be taken in his event?

입력

The first line contains an integer $R$ (1ドル ≤ R ≤ 1000$) indicating the number of runners. Each of the next $R$ lines describes a runner with two integers $T$ (0ドル ≤ T ≤ 10^9$) and $S$ (1ドル ≤ S ≤ 10^9$), representing respectively the starting time and the speed of the runner.

The next line contains an integer $P$ (1ドル ≤ P ≤ 10^6$) denoting the number of photos. Each of the next $P$ lines describes a photo with three integers $U$ (0ドル ≤ U ≤ 10^9$), $A$ and $B$ (0ドル ≤ A ≤ B ≤ 10^9$), specifying that the photo will be taken at time $U$ and will cover the segment $[A, B]$ of the track.

The next line contains an integer $Q$ (1ドル ≤ Q ≤ 1000$) indicating the number of queries. Each of the next $Q$ lines describes a query with two integers $T'$ (0ドル ≤ T' ≤ 10^9$) and $S'$ (1ドル ≤ S' ≤ 10^9$), representing respectively a possible starting time and speed for Johnny.

출력

Output $Q$ lines, each line with an integer indicating the number of trash photos for the corresponding query of the input.

제한

예제 입력 1

3
0 1
2 2
4 2
3
1 2 4
5 8 16
3 1 8
3
3 1
1 3
0 2

예제 출력 1

2
1
0

힌트

출처

ICPC > Regionals > Latin America > Latin America Regional Contests > Latin America Regional Contests 2022 J번

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

출처

대학교 대회

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

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