結果

問題 No.165 四角で囲え!
ユーザー roarisroaris
提出日時 2019-12-06 01:33:11
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,237 bytes
コンパイル時間 1,937 ms
コンパイル使用メモリ 86,760 KB
実行使用メモリ 84,636 KB
最終ジャッジ日時 2023-08-24 19:32:40
合計ジャッジ時間 20,312 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,368 ms
78,424 KB
testcase_01 AC 73 ms
71,420 KB
testcase_02 AC 73 ms
71,124 KB
testcase_03 AC 72 ms
71,308 KB
testcase_04 AC 75 ms
71,296 KB
testcase_05 AC 2,944 ms
78,260 KB
testcase_06 AC 651 ms
78,468 KB
testcase_07 AC 72 ms
71,240 KB
testcase_08 AC 71 ms
71,276 KB
testcase_09 AC 72 ms
71,112 KB
testcase_10 AC 71 ms
71,068 KB
testcase_11 AC 3,057 ms
78,664 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *

N, B = map(int, input().split())
XYP = [tuple(map(int, input().split())) for _ in range(N)]
XYP.sort(key=lambda k: k[0])
ans = 0

for i in range(N):
    Xi, _, _ = XYP[i]
    
    for j in range(i, N):
        Xj, _, _ = XYP[j]
        YP = []
        
        for k in range(N):
            Xk, Yk, Pk = XYP[k]
            
            if Xi<=Xk<=Xj:
                YP.append((Yk, Pk))
        
        YP.sort(key=lambda k: k[0])
        YP += [('a', 'a')]
        cnt = []
        point = []
        c = 0
        p = 0
        
        for i in range(len(YP)-1):
            c += 1
            p += YP[i][1]
            
            if YP[i][0]!=YP[i+1][0]:
                cnt.append(c)
                point.append(p)
                c = 0
                p = 0
        
        r = 0
        cur_c = 0
        cur_p = 0
        
        for l in range(len(cnt)):
            while r<len(cnt) and cur_p+point[r]<=B:
                cur_c += cnt[r]
                cur_p += point[r]
                r += 1
            
            ans = max(ans, cur_c)
            
            if l==r:
                r += 1
            else:
                cur_c -= cnt[l]
                cur_p -= point[l]
    
print(ans)
0