結果
問題 | No.165 四角で囲え! |
ユーザー | しらっ亭 |
提出日時 | 2015-07-05 04:14:46 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 975 ms / 5,000 ms |
コード長 | 1,691 bytes |
コンパイル時間 | 331 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 79,788 KB |
最終ジャッジ日時 | 2024-06-07 19:09:32 |
合計ジャッジ時間 | 5,867 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 236 ms
78,340 KB |
testcase_01 | AC | 39 ms
51,968 KB |
testcase_02 | AC | 43 ms
52,224 KB |
testcase_03 | AC | 39 ms
51,968 KB |
testcase_04 | AC | 41 ms
52,352 KB |
testcase_05 | AC | 347 ms
78,140 KB |
testcase_06 | AC | 174 ms
75,952 KB |
testcase_07 | AC | 42 ms
52,224 KB |
testcase_08 | AC | 40 ms
51,968 KB |
testcase_09 | AC | 40 ms
52,608 KB |
testcase_10 | AC | 41 ms
52,224 KB |
testcase_11 | AC | 186 ms
77,232 KB |
testcase_12 | AC | 99 ms
72,808 KB |
testcase_13 | AC | 131 ms
76,544 KB |
testcase_14 | AC | 93 ms
73,088 KB |
testcase_15 | AC | 87 ms
69,504 KB |
testcase_16 | AC | 429 ms
79,104 KB |
testcase_17 | AC | 300 ms
79,180 KB |
testcase_18 | AC | 975 ms
79,788 KB |
testcase_19 | AC | 354 ms
79,404 KB |
testcase_20 | AC | 292 ms
74,240 KB |
testcase_21 | AC | 300 ms
79,488 KB |
testcase_22 | AC | 293 ms
74,112 KB |
ソースコード
def zip(X): l = list(set(X)) l.sort() ma = l[-1] d = {x: i + 1 for i, x in enumerate(l)} return [d[x] for x in X], d[ma] + 1 def solve(N, B, X, Y, P): X, ma_x = zip(X) Y, ma_y = zip(Y) M = [[0] * ma_x for i in range(ma_y)] for i in range(N): M[Y[i]][X[i]] = P[i] S = [[0] * ma_x for i in range(ma_y)] C = [[0] * ma_x for i in range(ma_y)] for y in range(1, ma_y): sy1 = S[y - 1] cy1 = C[y - 1] my = M[y] sy = S[y] cy = C[y] for x in range(1, ma_x): m = my[x] sy[x] = sy[x - 1] + sy1[x] - sy1[x - 1] + m if m: cy[x] = cy[x - 1] + cy1[x] - cy1[x - 1] + 1 else: cy[x] = cy[x - 1] + cy1[x] - cy1[x - 1] ma = 0 for y1 in range(0, ma_y): sy1 = S[y1] cy1 = C[y1] for y2 in range(y1 + 1, ma_y): sy2 = S[y2] cy2 = C[y2] x1 = 0 x2 = 1 while x2 < ma_x: s = sy2[x2] - sy2[x1] - sy1[x2] + sy1[x1] if s <= B: c = cy2[x2] - cy2[x1] - cy1[x2] + cy1[x1] ma = max(ma, c) x2 += 1 else: if x1 == x2: x2 += 1 else: x1 += 1 print(ma) def main(): N, B = list(map(int, input().split())) X = [0] * N Y = [0] * N P = [0] * N for i in range(N): x, y, p = list(map(int, input().split())) X[i] = x Y[i] = y P[i] = p solve(N, B, X, Y, P) if __name__ == '__main__': main()