結果

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

ソースコード

diff #

from itertools import permutations

N = int(input())

p_s = []

for n in range(N):
    L, R = map(int, input().split())
    p_s.append((L, R))

n_s = [n for n in range(1, N + 1)]

n_ps = permutations(n_s, N)

count = 0
for n_p in n_ps:
    is_true = True
    min_diff = 0
    for n in range(N):
        now_p = p_s[n_p[n] - 1]
        l_diff = now_p[0]
        r_diff = now_p[1]
        if min_diff > r_diff:
            is_true = False
            break
        min_diff = max(min_diff, l_diff)
        
    
    if is_true:
        # print(n_p)
        count += 1

print(count)
0