結果

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

ソースコード

diff #
raw source code

m=lambda x:[*map(int,x.split())]
A,B,*C=open(0)
N,M=m(A)
H=0,*m(B)
G=[[]for i in range(N+1)]
for s in C:a,b=m(s);G[a]+=b,;G[b]+=a,
D=[]
for c in 1,N:
 S=[-1e9]*-~N;S[c]=0;Q=[[c,0]]
 for t,d in Q:
  if d<S[t]:continue
  for n in G[t]:
   if H[n]>H[t]and S[n]<=S[t]:S[n]=S[t]+1;Q+=[n,S[n]],
 D+=S,
print(max(-2,*map(sum,zip(*D)))+1)
0