結果

問題 No.572 妖精の演奏
ユーザー cielciel
提出日時 2017-10-08 00:27:10
言語 Ruby
(3.3.0)
結果
AC  
実行時間 243 ms / 2,000 ms
コード長 319 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 11,424 KB
実行使用メモリ 15,664 KB
最終ジャッジ日時 2023-08-10 19:38:48
合計ジャッジ時間 3,362 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
15,036 KB
testcase_01 AC 82 ms
15,264 KB
testcase_02 AC 79 ms
15,072 KB
testcase_03 AC 79 ms
15,292 KB
testcase_04 AC 77 ms
15,268 KB
testcase_05 AC 92 ms
15,312 KB
testcase_06 AC 86 ms
15,544 KB
testcase_07 AC 79 ms
15,116 KB
testcase_08 AC 81 ms
15,308 KB
testcase_09 AC 87 ms
15,312 KB
testcase_10 AC 146 ms
15,528 KB
testcase_11 AC 183 ms
15,424 KB
testcase_12 AC 200 ms
15,428 KB
testcase_13 AC 243 ms
15,664 KB
testcase_14 AC 108 ms
15,320 KB
testcase_15 AC 118 ms
15,332 KB
testcase_16 AC 102 ms
15,300 KB
testcase_17 AC 120 ms
15,520 KB
testcase_18 AC 79 ms
15,144 KB
testcase_19 AC 75 ms
15,124 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def mul(a,b)
	r=a.size.times.map{[0]*b[0].size}
	a.size.times{|y|
		b[0].size.times{|x|
			r[y][x]=b.size.times.reduce(0){|s,i|[s,a[y][i]+b[i][x]].max}
		}
	}
	r
end
n=gets.to_i-1
m=gets.to_i
e=m.times.map{|i|[0]*m}
a=$<.map{|e|e.split.map &:to_i}
while n>0
	e=mul(e,a) if n%2>0
	a=mul(a,a)
	n/=2
end
p e.map(&:max).max
0