結果

問題 No.3262 水色コーダーさん、その問題d問題ですよ?(1<=d<=N)
ユーザー Tatsu_mr
提出日時 2025-09-06 14:13:40
言語 Ruby
(3.4.1)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 442 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 7,936 KB
実行使用メモリ 13,184 KB
最終ジャッジ日時 2025-09-06 14:13:51
合計ジャッジ時間 4,330 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
l = []
r = []
n.times do
    x, y = gets.split.map(&:to_i)
    l << x
    r << y
end

idx = []
(0..n - 1).each do |i|
    idx << i
end

ans = 0
idx.permutation do |id|
    ok = true
    x = 0
    (0..n - 1).each do |i|
        if r[id[i]] < x then
            ok = false
            break
        end
        if x < l[id[i]] then
            x = l[id[i]]
        end
    end
    if ok then
        ans += 1
    end
end

puts ans
0