結果
| 問題 | No.3282 Photos and Friends | 
| コンテスト | |
| ユーザー |  timi | 
| 提出日時 | 2025-09-26 22:41:39 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 429 ms / 2,000 ms | 
| コード長 | 601 bytes | 
| コンパイル時間 | 389 ms | 
| コンパイル使用メモリ | 82,360 KB | 
| 実行使用メモリ | 123,648 KB | 
| 最終ジャッジ日時 | 2025-09-26 22:41:51 | 
| 合計ジャッジ時間 | 10,963 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 50 | 
ソースコード
N,P,Q=map(int, input().split())
A=[]
f=1
l,r=0,0 
ll,rr=0,0
for i in range(N):
  x,a,b=map(int, input().split())
  a=min(a,x)
  b=min(b,x)
  A.append((x,a,b))
  if a+b<x:
    f=-1 
  l+=x-b;r+=a 
  ll+=x-a;rr+=b 
  
u,v=P-l,rr-Q 
if u<0:
  f=-1
if v>=0 and u<v:
  f=-1 
if f==-1:
  print('No')
  exit()
if v<0:
  plus=0 
if u>=0 and v>=0:
  plus=min(u,v)
  
ans=[]
pp,qq=0,0
for x,a,b in A:
  p,q=x-b,b
  w=max(0,a-(x-b))
  w=min(plus,w)
  p+=w;q-=w 
  plus-=w 
  ans.append((p,q))
  pp+=p 
  qq+=q 
  
if plus!=0:
  f=-1
if f==-1:
  print('No')
  exit()
  
print('Yes')
for x,y in ans:
  print(x,y)
            
            
            
        