結果

問題 No.1473 おでぶなおばけさん
ユーザー 小野寺健小野寺健
提出日時 2021-10-31 08:58:21
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 586 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 45,184 KB
最終ジャッジ日時 2024-04-17 00:53:32
合計ジャッジ時間 44,612 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
17,664 KB
testcase_01 AC 91 ms
12,160 KB
testcase_02 AC 1,448 ms
44,800 KB
testcase_03 AC 1,956 ms
43,776 KB
testcase_04 AC 542 ms
27,904 KB
testcase_05 AC 315 ms
20,992 KB
testcase_06 TLE -
testcase_07 AC 850 ms
44,416 KB
testcase_08 AC 863 ms
44,416 KB
testcase_09 AC 817 ms
44,416 KB
testcase_10 AC 1,068 ms
24,576 KB
testcase_11 AC 1,292 ms
24,320 KB
testcase_12 AC 1,376 ms
24,320 KB
testcase_13 AC 588 ms
20,096 KB
testcase_14 AC 423 ms
17,792 KB
testcase_15 AC 867 ms
22,912 KB
testcase_16 AC 1,106 ms
24,192 KB
testcase_17 AC 131 ms
12,928 KB
testcase_18 AC 165 ms
13,440 KB
testcase_19 AC 1,235 ms
31,360 KB
testcase_20 AC 1,726 ms
39,936 KB
testcase_21 AC 1,436 ms
37,376 KB
testcase_22 AC 642 ms
41,344 KB
testcase_23 AC 601 ms
32,896 KB
testcase_24 AC 585 ms
33,024 KB
testcase_25 AC 662 ms
38,272 KB
testcase_26 AC 707 ms
38,784 KB
testcase_27 AC 257 ms
19,968 KB
testcase_28 AC 967 ms
44,160 KB
testcase_29 AC 1,472 ms
39,424 KB
testcase_30 AC 1,911 ms
43,904 KB
testcase_31 AC 1,001 ms
44,928 KB
testcase_32 TLE -
testcase_33 AC 1,465 ms
39,424 KB
testcase_34 AC 546 ms
27,264 KB
testcase_35 AC 790 ms
27,520 KB
testcase_36 AC 532 ms
28,544 KB
testcase_37 AC 574 ms
31,232 KB
testcase_38 AC 157 ms
15,488 KB
testcase_39 AC 1,000 ms
24,832 KB
testcase_40 AC 1,056 ms
24,704 KB
testcase_41 AC 421 ms
24,960 KB
testcase_42 AC 411 ms
25,344 KB
testcase_43 TLE -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, m = gets.split(" ").map{|s| s.to_i}

w = Array.new(n) {Array.new(2, -Float::INFINITY)}
0.upto(n-1) {|i|
	w[i][1] = Float::INFINITY
}
w[0][0] = Float::INFINITY

v = Array.new(n) {Array.new}

m.times {
	s, t, d = gets.split(" ").map{|s| s.to_i}
	v[s-1] << [t-1, d]
	v[t-1] << [s-1, d]
}
	
que = [[0, Float::INFINITY, 0]]

while que.length > 0 do
	cv, cd, ci = que.shift
	v[cv].each {|nv, nd|
		nd = cd if cd < nd
		if nd > w[nv][0] or (nd == w[nv][0] and ci+1 < w[nv][1]) then
			w[nv] = [nd, ci+1]
			que << [nv, nd, ci+1] if nv != n-1
		end
	}		
end

puts "#{w[n-1][0]} #{w[n-1][1]}"
0