結果

問題 No.165 四角で囲え!
ユーザー chocoruskchocorusk
提出日時 2020-09-18 18:27:07
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 707 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 86,808 KB
実行使用メモリ 83,960 KB
最終ジャッジ日時 2023-09-04 08:59:05
合計ジャッジ時間 18,255 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 75 ms
71,136 KB
testcase_02 AC 74 ms
71,016 KB
testcase_03 AC 74 ms
71,216 KB
testcase_04 AC 76 ms
71,188 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines

n, b=map(int, readline().split())
xyp=list(map(int, read().split()))
xs=xyp[::3]
ys=xyp[1::3]
ps=xyp[2::3]
ans=0
for xl in xs:
    for xr in xs:
        if xl>xr:
            continue
        z=[(y, p) for x, y, p in zip(xs, ys, ps) if xl<=x and x<=xr]
        z.sort()
        s=0
        l=0
        for r, q in enumerate(z):
            s+=q[1]
            if r<len(z)-1 and z[r+1][0]==q[0]:
                continue
            while l<=r and (s>b or (l>0 and z[l-1][0]==z[l][0])):
                s-=z[l][1]
                l+=1
            if ans<r-l+1:
                ans=r-l+1
print(ans)
0