問題一覧 > 通常問題

No.3282 Photos and Friends

レベル : / AI推定難易度 : 1150 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 60
作問者 : hirayuu_yc / テスター : highlighter
お気に入りにしたユーザー ProblemId : 12204 / 自分の提出
問題文最終更新日: 2025-09-24 13:20:48
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 484 (順位表) の他の問題:

Problem Statement

Giving photos to Friends makes the Friends stronger. How this works is a mystery.

Photos have special effects and are divided into $2$ types according to their activation conditions. Here, we simply call them type $1$ and type $2$.

There are $N$ Friends, numbered $1,2,\dots,N$.

The Captain has $P$ photos of type $1$ and $Q$ photos of type $2$. Friend $i$ wants to hold $X_i$ photos, but can hold at most $A_i$ photos of type $1$ and at most $B_i$ photos of type $2$.

The Captain wonders whether it is possible to give photos to the Friends so as to meet all of their wishes. Determine whether it is possible to give each Friend exactly $X_i$ photos, and if it is possible, output one such way.

Constraints

  • $1\leq N\leq 2\times 10^5$
  • $0\leq P,Q\leq 10^{18}$
  • $1\leq X_i\leq 10^9$
  • $0\leq A_i,B_i\leq 10^9$
  • All input values are integers.

Input

$N$ $P$ $Q$
$X_1$ $A_1$ $B_1$
$X_2$ $A_2$ $B_2$
$\vdots$
$X_N$ $A_N$ $B_N$

Output

If there is no way of giving photos that satisfies the conditions, output No.

If there is one, output $N+1$ lines.

On line $1$, output Yes. On line $i+1$, output the number of type $1$ photos and the number of type $2$ photos given to Friend $i$, in this order, separated by a space.

If there are multiple ways of giving photos, any of them will be accepted.

Sample

Sample 1
Input
3 3 4
2 2 1
3 3 2
2 0 2
Output
Yes
1 1
2 1
0 2

It is easy to verify that this way of giving photos satisfies the conditions.

Swapping the type $2$ photo given to Friend $1$ with a type $1$ photo given to Friend $2$ is also judged as correct.

Sample 2
Input
3 3 4
2 1 2 
3 1 3
2 0 2
Output
No

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。