포럼
문제 ICPC00271

J. Joining Flows

설명

Having recently taken over the Wonka Factory, Charlie is now in charge of the day-to-day production of the various chocolate products made there. While this may seem like a cushy job with an all-you-can-eat-chocolate perk, it also comes with the difficult responsibility of keeping the (somewhat convoluted and complicated) production lines working.

The heart of the factory is the Chocolate River, where raw molten chocolate flows from \(k\) chocolate-producing faucets, to outlets where different types of pralines and choclate bars are made. The \(i\)'th of the \(k\) chocolate faucets produces chocolate at some fixed temperature \(t_i\), and the amount of chocolate flowing from the faucet can be adjusted to any value between \(a_i\) and \(b_i\) millilitres per second. Suppose the \(k\) taps are adjusted to produce \(x_1, x_2, \ldots, x_k\) millilitres of chocolates per second respectively (where \(a_i \le x_i \le b_i\)). Then the total flow in the Chocolate river is \(x_1 + x_2 + \ldots + x_k\), and its temperature is the weighted average [
\frac{x_1 t_1 + x_2t_2 + \ldots +
x_kt_k}{x_1 + x_2 + \ldots + x_k}
] (each faucet produces grade A quality chocolate which instantly mixes with the chocolate from the other faucets).

Each type of praline and chocolate bar produced at the factory requires the Chocolate River to be adjusted to have a specific temperature and flow level. Charlie recently came across a long list of new praline recipes, and would now like to figure out which of these are even possible to make at the factory. Write a program to determine, for each of the new recipes, if its required temperature and flow level is possible to achieve with some setting of the \(k\) faucets.

제약
입력 형식

The first line of input contains an integer \(k\) (\(1 \le k \le 10\)), the number of taps. Then follow \(k\) lines, describing the taps. The \(i\)'th of these lines contains the three integers \(t_i\), \(a_i\), and \(b_i\) (\(0 \le t_i \le 10^6\), \(0 \le a_i \le b_i \le 10^6\)) describing the \(i\)'th faucet.

Next follows a line containing an integer \(r\) (\(1 \le r \le 10^5\)), the number of new recipes to check. Then follows \(r\) lines, each describing a recipe. A recipe is described by two integers \(\tau\) and \(\phi\) (\(0 \le \tau \le 10^6\) and \(1 \le \phi \le 10^6\)), where \(\tau\) is the chocolate temperature and \(\phi\) the chocolate flow needed for this recipe.

출력 형식

For each of the \(r\) recipes, print one line with the string "yes" if it is possible to achieve the desired combination of chocolate temperature and flow, and "no" otherwise.

예제 1
입력
2
50 0 100
100 50 100
3
20 75
75 150
75 90
출력
no
yes
no
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NCPC 2020

평가 및 의견

J. Joining Flows

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

J. Joining Flows

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8