結果
問題 | No.165 四角で囲え! |
ユーザー | ckawatak |
提出日時 | 2017-09-19 18:14:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,513 ms / 5,000 ms |
コード長 | 1,732 bytes |
コンパイル時間 | 288 ms |
コンパイル使用メモリ | 82,588 KB |
実行使用メモリ | 77,280 KB |
最終ジャッジ日時 | 2024-06-07 19:14:02 |
合計ジャッジ時間 | 13,854 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 412 ms
75,520 KB |
testcase_01 | AC | 39 ms
51,712 KB |
testcase_02 | AC | 39 ms
52,224 KB |
testcase_03 | AC | 39 ms
52,224 KB |
testcase_04 | AC | 41 ms
52,224 KB |
testcase_05 | AC | 557 ms
75,808 KB |
testcase_06 | AC | 243 ms
73,856 KB |
testcase_07 | AC | 39 ms
52,352 KB |
testcase_08 | AC | 38 ms
51,584 KB |
testcase_09 | AC | 38 ms
51,712 KB |
testcase_10 | AC | 37 ms
51,968 KB |
testcase_11 | AC | 803 ms
77,280 KB |
testcase_12 | AC | 816 ms
76,512 KB |
testcase_13 | AC | 1,179 ms
76,144 KB |
testcase_14 | AC | 1,235 ms
76,024 KB |
testcase_15 | AC | 1,116 ms
76,944 KB |
testcase_16 | AC | 849 ms
76,836 KB |
testcase_17 | AC | 562 ms
76,580 KB |
testcase_18 | AC | 1,513 ms
76,160 KB |
testcase_19 | AC | 625 ms
76,496 KB |
testcase_20 | AC | 569 ms
75,904 KB |
testcase_21 | AC | 538 ms
69,248 KB |
testcase_22 | AC | 536 ms
69,120 KB |
ソースコード
def compression_mapping(xs): ys = [] for i in range(len(xs)): ys.append(i) ys.sort(key=xs.__getitem__) m = {} for i in ys: if xs[i] not in m: index = len(m) m[xs[i]] = index return m def compress(m, xs): ys = [] for i in range(len(xs)): ys.append(m[xs[i]]) return ys N,B = list(map(int, input().split(' '))) X = [0 for _ in range(N)] Y = [0 for _ in range(N)] P = [0 for _ in range(N)] for i in range(N): X[i],Y[i],P[i] = list(map(int, input().split(' '))) X = compress(compression_mapping(X), X) Y = compress(compression_mapping(Y), Y) index = [] for i in range(N): index.append(i) index.sort(key=X.__getitem__) solution = 0 for top in range(N+1): for bottom in range(top): count = 0 score = 0 right_end = 0 right_pointer = 0 left_end = 0 left_pointer = 0 while right_end < N: right_end += 1 while right_pointer < N and X[index[right_pointer]] < right_end: if bottom <= Y[index[right_pointer]] and Y[index[right_pointer]] < top: count += 1 score += P[index[right_pointer]] right_pointer += 1 while B < score: left_end += 1 while left_pointer < N and X[index[left_pointer]] < left_end: if bottom <= Y[index[left_pointer]] and Y[index[left_pointer]] < top: count -= 1 score -= P[index[left_pointer]] left_pointer += 1 solution = max(solution, count) print(solution)