結果

問題 No.3386 Up Down Hiking (Python)
コンテスト
ユーザー Yu_212
提出日時 2025-11-22 14:58:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 303 bytes
コンパイル時間 344 ms
コンパイル使用メモリ 82,148 KB
実行使用メモリ 250,232 KB
最終ジャッジ日時 2025-11-22 14:59:00
合計ジャッジ時間 24,989 ms
ジャッジサーバーID
(参考情報)
judge4 / judge7
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 42 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

I=lambda:map(int,input().split())
n,m=I()
*h,=I()
*e,=eval("[],"*n)
for i in[0]*m:
 a,b=I()
 if h[a-1]<h[b-1]:a,b=b,a
 e[a-1]+=b-1,
def f(k):
 t=[~n]*n
 t[k]=0
 for i in sorted(range(n),key=lambda x:h[x]):
  for v in e[i]:t[i]=max(t[i],t[v]+1)
 return t
print(max(-1,max(map(int.__add__,f(0),f(-1)))+1))
0