結果

問題 No.497 入れ子の箱
ユーザー nanaenanae
提出日時 2017-03-25 00:03:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 959 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 8,572 KB
最終ジャッジ日時 2023-09-20 06:48:32
合計ジャッジ時間 3,938 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,100 KB
testcase_01 AC 18 ms
7,908 KB
testcase_02 AC 16 ms
7,908 KB
testcase_03 AC 195 ms
8,424 KB
testcase_04 AC 195 ms
8,476 KB
testcase_05 AC 198 ms
8,348 KB
testcase_06 AC 192 ms
8,564 KB
testcase_07 AC 194 ms
8,512 KB
testcase_08 AC 194 ms
8,360 KB
testcase_09 AC 195 ms
8,468 KB
testcase_10 AC 194 ms
8,508 KB
testcase_11 AC 193 ms
8,476 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 21 ms
8,480 KB
testcase_24 AC 21 ms
8,472 KB
testcase_25 AC 19 ms
7,944 KB
testcase_26 AC 19 ms
8,108 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 22 ms
8,560 KB
testcase_31 AC 23 ms
8,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from operator import itemgetter

def solve():
    N = int(input())
    hako = [sorted([int(i) for i in input().split()]) for j in range(N)]
    hako.sort(key=itemgetter(2))
    hako.sort(key=itemgetter(1))
    hako.sort(key=itemgetter(0))

    inf = 10**9

    dp = [[inf, inf, inf] for i in range(N)]
    dp[0] = hako[0]

    for i in range(1, N):
        for j in range(N):
            if not is_larger(dp[j], hako[i]):
                if is_larger(hako[i], dp[j]):
                    dp[j] = hako[i]

                break

        # print(dp)

    ans = len([tyoku for tyoku in dp if tyoku != [inf]*3])
    print(ans)

def is_larger(a, b):
    for i in range(3):
        if b[i] <= a[i]:
            return False

    return True

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()
0