結果

問題 No.1570 Blocks
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-06-27 14:39:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 413 ms / 2,000 ms
コード長 932 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 91,196 KB
最終ジャッジ日時 2023-09-07 17:54:23
合計ジャッジ時間 15,457 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,320 KB
testcase_01 AC 74 ms
71,364 KB
testcase_02 AC 289 ms
86,124 KB
testcase_03 AC 352 ms
87,300 KB
testcase_04 AC 255 ms
83,608 KB
testcase_05 AC 267 ms
83,656 KB
testcase_06 AC 279 ms
83,860 KB
testcase_07 AC 116 ms
78,160 KB
testcase_08 AC 342 ms
86,916 KB
testcase_09 AC 384 ms
88,104 KB
testcase_10 AC 311 ms
86,432 KB
testcase_11 AC 337 ms
87,496 KB
testcase_12 AC 405 ms
91,196 KB
testcase_13 AC 389 ms
90,760 KB
testcase_14 AC 398 ms
90,640 KB
testcase_15 AC 216 ms
82,524 KB
testcase_16 AC 397 ms
90,748 KB
testcase_17 AC 208 ms
83,112 KB
testcase_18 AC 329 ms
86,504 KB
testcase_19 AC 211 ms
82,988 KB
testcase_20 AC 214 ms
82,356 KB
testcase_21 AC 312 ms
86,748 KB
testcase_22 AC 76 ms
71,476 KB
testcase_23 AC 76 ms
71,488 KB
testcase_24 AC 74 ms
71,176 KB
testcase_25 AC 75 ms
71,264 KB
testcase_26 AC 74 ms
71,128 KB
testcase_27 AC 74 ms
71,064 KB
testcase_28 AC 75 ms
71,224 KB
testcase_29 AC 75 ms
71,304 KB
testcase_30 AC 75 ms
71,388 KB
testcase_31 AC 76 ms
71,480 KB
testcase_32 AC 379 ms
88,128 KB
testcase_33 AC 413 ms
90,512 KB
testcase_34 AC 367 ms
87,488 KB
testcase_35 AC 404 ms
90,876 KB
testcase_36 AC 385 ms
90,568 KB
testcase_37 AC 378 ms
88,260 KB
testcase_38 AC 384 ms
88,168 KB
testcase_39 AC 396 ms
90,672 KB
testcase_40 AC 386 ms
90,872 KB
testcase_41 AC 408 ms
90,360 KB
testcase_42 AC 406 ms
90,824 KB
testcase_43 AC 406 ms
90,668 KB
testcase_44 AC 405 ms
90,960 KB
testcase_45 AC 407 ms
90,760 KB
testcase_46 AC 402 ms
90,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

https://yukicoder.me/problems/no/1570

Zabuton まんま?
あ、2乗を直さないと

"""

"""
https://atcoder.jp/contests/cf17-final/tasks/cf17_final_d

全て置けるかの判定を考える
H+Pで昇順ソート
後ろから見ていって、その時点での座布団がH+P以下なら○ だめならX
を付けてPを引く
を繰り返し、全て○なら全員置ける(丸の数以上の答えであることが確定する)

あとは前から見ていってdp?
dp[i][j] = i人目まで見てj人置いた時の最小の枚数
→H+Pでソートするのが正しいなら絶対おkなんだが…

"""

import sys
N = int(input())

SHP = []

for i in range(N):

    p,h = map(int,input().split())
    SHP.append( (h+p,h,p) )

SHP.sort()
now = 0

for i in range(N):

    s,h,p = SHP[i]
    A,B = p,h

    if now <= B:
        now += A
    else:
        print ("No")
        sys.exit()
        
print ("Yes")
0