結果

問題 No.1570 Blocks
ユーザー ygd.ygd.
提出日時 2021-06-29 18:42:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,100 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 87,320 KB
実行使用メモリ 87,384 KB
最終ジャッジ日時 2023-09-08 03:47:15
合計ジャッジ時間 11,124 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,692 KB
testcase_01 AC 69 ms
71,352 KB
testcase_02 AC 186 ms
81,628 KB
testcase_03 AC 216 ms
81,976 KB
testcase_04 AC 175 ms
80,824 KB
testcase_05 AC 176 ms
80,896 KB
testcase_06 AC 180 ms
80,692 KB
testcase_07 AC 103 ms
77,636 KB
testcase_08 AC 211 ms
82,248 KB
testcase_09 AC 229 ms
82,668 KB
testcase_10 AC 201 ms
81,496 KB
testcase_11 AC 214 ms
82,220 KB
testcase_12 AC 235 ms
82,444 KB
testcase_13 AC 233 ms
83,136 KB
testcase_14 AC 254 ms
86,440 KB
testcase_15 AC 153 ms
80,208 KB
testcase_16 AC 256 ms
87,384 KB
testcase_17 AC 154 ms
80,772 KB
testcase_18 AC 206 ms
81,576 KB
testcase_19 AC 152 ms
80,696 KB
testcase_20 AC 150 ms
80,456 KB
testcase_21 AC 207 ms
83,644 KB
testcase_22 AC 71 ms
71,100 KB
testcase_23 AC 73 ms
71,460 KB
testcase_24 AC 72 ms
71,624 KB
testcase_25 AC 71 ms
71,288 KB
testcase_26 AC 73 ms
71,144 KB
testcase_27 AC 72 ms
71,376 KB
testcase_28 AC 72 ms
71,524 KB
testcase_29 AC 69 ms
71,300 KB
testcase_30 AC 71 ms
71,464 KB
testcase_31 AC 71 ms
71,152 KB
testcase_32 AC 228 ms
82,792 KB
testcase_33 AC 233 ms
82,748 KB
testcase_34 AC 223 ms
82,092 KB
testcase_35 AC 237 ms
82,696 KB
testcase_36 AC 230 ms
82,964 KB
testcase_37 AC 226 ms
82,492 KB
testcase_38 WA -
testcase_39 AC 255 ms
86,740 KB
testcase_40 AC 228 ms
82,880 KB
testcase_41 AC 237 ms
82,520 KB
testcase_42 AC 250 ms
84,432 KB
testcase_43 AC 252 ms
84,596 KB
testcase_44 AC 251 ms
84,692 KB
testcase_45 AC 251 ms
84,756 KB
testcase_46 AC 239 ms
82,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N = int(input())
    Z = []
    for i in range(N):
        a,b = map(int,input().split())
        Z.append((a,b))
    Z.sort(key = lambda x: x[1])
    #print(Z)

    w = 0
    hold = -1
    for i in range(N):
        a,b = Z[i]
        if hold != -1: #何かをキープしている
            ha,hb = Z[hold]
            if w <= hb and w + ha <= b: #間にHoldを入れることができる
                hold = -1
                w += ha + a
            else: #入れられない
                if w > b:
                    #print(i,hold,w,b)
                    print("No");exit()
                else:
                    w += a
        else:
            if w > b:
                hold = i - 1
                w -= Z[hold][0]
                if w > b:
                    print("No");exit()
                else:
                    w += a
            else:
                w += a
    if hold == -1:
        print("Yes")
    else:
        ha,hb = Z[hold]
        if w > hb:
            print("No")
        else:
            print("Yes")

if __name__ == '__main__':
    main()
0