結果

問題 No.497 入れ子の箱
ユーザー nanae
提出日時 2017-03-25 01:26:46
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 758 ms / 5,000 ms
コード長 648 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-07-06 03:25:10
合計ジャッジ時間 20,123 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

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

    inf = 10**9

    dp = [1] * N

    for i in range(N - 2, -1, -1):
        for j in range(i + 1, N):
            if is_larger(hako[i], hako[j]):
                dp[i] = max(dp[i], dp[j] + 1)

    ans = max(dp)

    print(ans)

def is_larger(a, b):
    return all(ai < bi for ai, bi in zip(a, b))

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