結果

問題 No.1570 Blocks
ユーザー moharan627moharan627
提出日時 2021-06-27 15:31:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,065 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 30,464 KB
最終ジャッジ日時 2023-09-07 17:41:40
合計ジャッジ時間 11,145 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,428 KB
testcase_01 AC 17 ms
8,468 KB
testcase_02 AC 155 ms
22,616 KB
testcase_03 AC 306 ms
27,100 KB
testcase_04 AC 139 ms
20,896 KB
testcase_05 AC 146 ms
21,656 KB
testcase_06 AC 226 ms
22,636 KB
testcase_07 AC 32 ms
10,264 KB
testcase_08 AC 300 ms
26,428 KB
testcase_09 AC 343 ms
29,212 KB
testcase_10 AC 182 ms
24,672 KB
testcase_11 AC 200 ms
26,652 KB
testcase_12 AC 360 ms
30,004 KB
testcase_13 AC 225 ms
29,536 KB
testcase_14 AC 239 ms
30,064 KB
testcase_15 AC 101 ms
17,932 KB
testcase_16 AC 233 ms
29,652 KB
testcase_17 AC 141 ms
17,760 KB
testcase_18 AC 183 ms
25,472 KB
testcase_19 AC 138 ms
17,840 KB
testcase_20 AC 98 ms
17,616 KB
testcase_21 AC 252 ms
24,504 KB
testcase_22 AC 17 ms
8,292 KB
testcase_23 AC 17 ms
8,312 KB
testcase_24 AC 17 ms
8,304 KB
testcase_25 AC 17 ms
8,328 KB
testcase_26 AC 17 ms
8,340 KB
testcase_27 AC 17 ms
8,328 KB
testcase_28 AC 17 ms
8,288 KB
testcase_29 AC 17 ms
8,476 KB
testcase_30 AC 17 ms
8,428 KB
testcase_31 AC 17 ms
8,300 KB
testcase_32 AC 361 ms
29,768 KB
testcase_33 AC 366 ms
30,176 KB
testcase_34 AC 220 ms
27,964 KB
testcase_35 AC 350 ms
29,944 KB
testcase_36 AC 224 ms
28,868 KB
testcase_37 AC 324 ms
28,904 KB
testcase_38 WA -
testcase_39 AC 232 ms
29,800 KB
testcase_40 AC 216 ms
28,976 KB
testcase_41 AC 361 ms
29,692 KB
testcase_42 AC 247 ms
30,208 KB
testcase_43 AC 247 ms
30,284 KB
testcase_44 AC 240 ms
30,184 KB
testcase_45 AC 242 ms
30,128 KB
testcase_46 AC 373 ms
30,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#sys.setrecursionlimit(10 ** 6)
INF = float('inf')
#10**20に変えるのもあり
MOD = 10**9 + 7
MOD2 = 998244353
def solve():
    def II(): return int(sys.stdin.readline())
    def LI(): return list(map(int, sys.stdin.readline().split()))
    def LC(): return list(input())
    def IC(): return [int(c) for c in input()]
    def MI(): return map(int, sys.stdin.readline().split())
    N = II()
    Block = [0]*N
    Asum = 0
    for n in range(N):
        A,B = MI()
        Block[n] = (A,B)
        Asum += A
    from operator import itemgetter
    Bs = sorted(Block, key = itemgetter(1,0),reverse=True)
    Acum = 0
    #print(Bs)
    I = 0
    from heapq import heappop, heappush
    H = []
    for n in range(N):
        while(I<N):
            a, b = Bs[I]
            if(Asum-(Acum+a) <= b):
                I+=1
                heappush(H,-a)
            else:
                break
        #print(H)
        if not H :
            print("No")
            exit()
        else:
            Acum += -heappop(H)
    print("Yes")
    return
solve()
0