結果
問題 | No.165 四角で囲え! |
ユーザー | ckawatak |
提出日時 | 2017-09-13 21:47:05 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,354 bytes |
コンパイル時間 | 105 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-11-07 20:05:11 |
合計ジャッジ時間 | 1,878 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 30 ms
10,880 KB |
testcase_03 | WA | - |
testcase_04 | AC | 30 ms
10,880 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 30 ms
10,752 KB |
testcase_09 | WA | - |
testcase_10 | AC | 31 ms
10,752 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 33 ms
10,880 KB |
testcase_18 | AC | 37 ms
10,752 KB |
testcase_19 | WA | - |
testcase_20 | AC | 32 ms
10,752 KB |
testcase_21 | AC | 33 ms
10,752 KB |
testcase_22 | AC | 32 ms
10,752 KB |
ソースコード
def lower_ends(points, axis): ends = [points[0]] for i in range(1, len(points)): if points[i][axis] == ends[0][axis]: ends.append(points[i]) else: break return ends def upper_ends(points, axis): ends = [points[-1]] for i in reversed(range(1, len(points)-1)): if points[i][axis] == ends[0][axis]: ends.append(points[i]) else: break return ends def score(points): total = 0 for p in points: total += p[2] return total N,B = list(map(int, input().split(' '))) total = 0 points = [] for n in range(N): x,y,p = list(map(int, input().split(' '))) points.append((x,y,p)) total += p horizontal = sorted(points, key=lambda point: point[0]) vertical = sorted(points, key=lambda point: point[1]) if total <= B: print(N) exit() while B < total: bottom = lower_ends(vertical, 1) top = upper_ends(vertical, 1) left = lower_ends(horizontal, 0) right = upper_ends(horizontal, 0) scores = { score(bottom): bottom, score(top): top, score(left): left, score(right): right } max = sorted(scores.keys())[-1] removed = scores[max] for r in removed: horizontal.remove(r) vertical.remove(r) total -= max print(len(horizontal))