結果

問題 No.165 四角で囲え!
ユーザー rlangevinrlangevin
提出日時 2023-07-27 12:06:04
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,028 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 82,500 KB
実行使用メモリ 86,464 KB
最終ジャッジ日時 2024-04-15 00:19:42
合計ジャッジ時間 36,125 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4,629 ms
78,352 KB
testcase_01 AC 40 ms
55,420 KB
testcase_02 AC 41 ms
54,260 KB
testcase_03 AC 41 ms
54,904 KB
testcase_04 AC 42 ms
54,916 KB
testcase_05 TLE -
testcase_06 AC 1,152 ms
76,992 KB
testcase_07 AC 41 ms
55,576 KB
testcase_08 AC 41 ms
54,988 KB
testcase_09 AC 41 ms
55,228 KB
testcase_10 AC 41 ms
54,984 KB
testcase_11 AC 4,107 ms
78,488 KB
testcase_12 AC 3,010 ms
78,444 KB
testcase_13 AC 1,495 ms
77,496 KB
testcase_14 AC 1,944 ms
77,656 KB
testcase_15 AC 2,056 ms
77,688 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N, B = map(int, input().split())
X, Y, P = [0] * N, [0] * N, [0] * N
XS = set()
for i in range(N):
    X[i], Y[i], P[i] = map(int, input().split())
    XS.add(X[i])

from collections import *
def solve(L):
    inf = 10 ** 18
    L.sort()
    K = len(L)
    L.append((inf, inf))
    Q = deque()
    now = -1
    val = 0
    temp = 0
    for i in range(K):
        Q.append(L[i])
        val += L[i][1]
        if L[i][0] == L[i + 1][0]:
            continue
        while Q:
            if val > B or Q[0][0] == now:
                now = Q[0][0]
                val -= Q[0][1]
                Q.popleft()
            else:
                break
        temp = max(temp, len(Q))
    return temp


XL = sorted(list(XS))
M = len(XL)
ans = 0
for i in range(M):
    for j in range(i, M):
        left = XL[i]
        right = XL[j]
        D = []
        for k in range(N):
            if left <= X[k] <= right:
                D.append((Y[k], P[k]))
        ans = max(ans, solve(D))

print(ans)
0