結果

問題 No.3262 水色コーダーさん、その問題d問題ですよ?(1<=d<=N)
コンテスト
ユーザー yt142857
提出日時 2025-09-06 13:26:17
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 101 ms / 2,000 ms
+ 656µs
コード長 906 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 236 ms
コンパイル使用メモリ 95,980 KB
実行使用メモリ 84,864 KB
最終ジャッジ日時 2026-07-14 19:01:44
合計ジャッジ時間 4,260 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n = int(input())
al = []
for i in range(n):
  a,b = map(int,input().split())
  al.append((a,b))
#次の順列を出力.もうなかったら-1を出します。
def Next_P(now):
  last_higher = -1
  nagasa = len(now)
  for i in range(nagasa-1):
    if now[i] < now[i+1]:
      last_higher = i
  if last_higher == -1:
    return -1
  else:
    last_higher_higher = -1
    for j in range(last_higher+1,nagasa):
      if now[last_higher] < now[j]:
        last_higher_higher = j
    now[last_higher],now[last_higher_higher] = now[last_higher_higher],now[last_higher]
    hanten = now[last_higher+1:]
    hanten = hanten[::-1]
    now = now[:last_higher+1] + hanten

    return now
now = list(range(n))
ans = 0
while now != -1:
  num = 0
  p = True
  for i in range(n):
    num = max(num,al[now[i]][0])
    if num > al[now[i]][1]:
      p = False
      break
  if p:
    ans += 1
  now = Next_P(now)
print(ans)
0