結果

問題 No.572 妖精の演奏
ユーザー cielciel
提出日時 2017-10-08 00:27:10
言語 Ruby
(3.3.0)
結果
AC  
実行時間 344 ms / 2,000 ms
コード長 319 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2024-04-28 12:56:47
合計ジャッジ時間 3,887 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
12,416 KB
testcase_01 AC 97 ms
12,160 KB
testcase_02 AC 91 ms
12,160 KB
testcase_03 AC 95 ms
12,288 KB
testcase_04 AC 100 ms
12,288 KB
testcase_05 AC 112 ms
12,544 KB
testcase_06 AC 111 ms
12,416 KB
testcase_07 AC 102 ms
12,160 KB
testcase_08 AC 106 ms
12,544 KB
testcase_09 AC 111 ms
12,544 KB
testcase_10 AC 191 ms
12,672 KB
testcase_11 AC 252 ms
12,800 KB
testcase_12 AC 283 ms
12,672 KB
testcase_13 AC 344 ms
12,544 KB
testcase_14 AC 146 ms
12,800 KB
testcase_15 AC 161 ms
12,672 KB
testcase_16 AC 143 ms
12,672 KB
testcase_17 AC 166 ms
12,800 KB
testcase_18 AC 100 ms
12,160 KB
testcase_19 AC 90 ms
12,288 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