結果

問題 No.3386 Up Down Hiking (Python)
コンテスト
ユーザー Yu_212
提出日時 2025-11-22 14:53:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,014 ms / 2,000 ms
コード長 312 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 82,600 KB
実行使用メモリ 249,460 KB
最終ジャッジ日時 2025-11-22 14:53:51
合計ジャッジ時間 25,941 ms
ジャッジサーバーID
(参考情報)
judge1 / judge7
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

I=lambda:map(int,input().split())
n,m=I()
*h,=I()
*e,=eval("[],"*n)
for i in range(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*2]*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(x+y for x,y in zip(f(0),f(-1)))+1))
0