結果

問題 No.3262 水色コーダーさん、その問題d問題ですよ?(1<=d<=N)
ユーザー Kazu
提出日時 2025-09-07 11:54:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 792 bytes
コンパイル時間 417 ms
コンパイル使用メモリ 82,784 KB
実行使用メモリ 87,484 KB
最終ジャッジ日時 2025-09-07 11:54:22
合計ジャッジ時間 4,657 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

problems = [i for i in range(1, N + 1)]
problem_scores = []

for _ in range(N):
    problem_scores.append(list(map(int, input().split())))

# problemsについて 1 ~ Nの順列を全て試す
# permは使わない


def permutations(list):
    if len(list) == 1:
        return [list]
    else:
        result = []
        for i, v in enumerate(list):
            rest = permutations(list[:i] + list[i+1:])
            for r in rest:
                perm = [v] + r
                result.append(perm)
        return result


ans = 0
for perm in permutations(problems):
    min_score = 0
    for p in perm:
        if problem_scores[p - 1][1] < min_score:
            break
        min_score = max(min_score, problem_scores[p - 1][0])
    else:
        ans += 1

print(ans)
0