結果

問題 No.2643 Many Range Sums Problems
ユーザー こめだわらこめだわら
提出日時 2024-02-19 23:31:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,454 ms / 8,000 ms
コード長 964 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 99,308 KB
最終ジャッジ日時 2024-02-19 23:32:05
合計ジャッジ時間 24,045 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 39 ms
53,460 KB
testcase_03 AC 875 ms
95,084 KB
testcase_04 AC 711 ms
89,964 KB
testcase_05 AC 693 ms
89,452 KB
testcase_06 AC 1,000 ms
99,308 KB
testcase_07 AC 943 ms
99,308 KB
testcase_08 AC 897 ms
96,364 KB
testcase_09 AC 1,025 ms
99,052 KB
testcase_10 AC 864 ms
95,980 KB
testcase_11 AC 668 ms
89,324 KB
testcase_12 AC 1,454 ms
99,308 KB
testcase_13 AC 1,119 ms
98,540 KB
testcase_14 AC 830 ms
96,620 KB
testcase_15 AC 883 ms
97,260 KB
testcase_16 AC 766 ms
92,524 KB
testcase_17 AC 789 ms
95,468 KB
testcase_18 AC 499 ms
82,556 KB
testcase_19 AC 140 ms
76,640 KB
testcase_20 AC 266 ms
78,772 KB
testcase_21 AC 137 ms
76,524 KB
testcase_22 AC 353 ms
79,436 KB
testcase_23 AC 573 ms
83,064 KB
testcase_24 AC 923 ms
92,780 KB
testcase_25 AC 842 ms
90,860 KB
testcase_26 AC 179 ms
76,920 KB
testcase_27 AC 179 ms
76,944 KB
testcase_28 AC 35 ms
53,460 KB
testcase_29 AC 36 ms
53,460 KB
testcase_30 AC 868 ms
99,180 KB
testcase_31 AC 927 ms
99,308 KB
testcase_32 AC 1,387 ms
99,180 KB
testcase_33 AC 1,400 ms
99,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())

def xx(t):
    a=t[0]
    b=t[1]
    if a==0:
        if 0<=b<=K:
            return (-10**18,10**18)
        else:
            return (10**18,-10**18)
    if a>0:
        l=(-b-1)//a+1
        r=(K-b)//a
        return (l,r)
    if a<0:
        a=-a
        b=-b
        l=(-K-b-1)//a+1
        r=(-b)//a
        return (l,r)
    
RX=[tuple(map(int,input().split())) for _ in range(N)]

for i in range(N):
    dp=[(0,0) for _ in range(N)]
    S=[(0,0) for _ in range(N+1)]
    for j in range(N-1,-1,-1):
        if i!=j:
            dp[j]=((S[RX[j][0]][0]-S[j+1][0]),RX[j][1]+(S[RX[j][0]][1]-S[j+1][1]))
            S[j]=(S[j+1][0]+dp[j][0],S[j+1][1]+dp[j][1])
        else:
            dp[j]=(1,0)
            S[j]=(S[j+1][0]+dp[j][0],S[j+1][1]+dp[j][1])
    l=-10**18
    r=10**18
    for j in range(N):
        ll,rr=xx(dp[j])
        l=max(l,ll)
        r=min(r,rr)
    if l<=r:
        print('Yes')
    else:
        print('No')
0