結果

問題 No.335 門松宝くじ
ユーザー cielciel
提出日時 2016-01-16 00:15:34
言語 Crystal
(1.11.2)
結果
TLE  
実行時間 -
コード長 580 bytes
コンパイル時間 17,834 ms
コンパイル使用メモリ 258,732 KB
実行使用メモリ 9,000 KB
最終ジャッジ日時 2023-09-13 09:02:56
合計ジャッジ時間 21,595 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,440 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,460 KB
testcase_03 AC 2 ms
4,464 KB
testcase_04 AC 3 ms
4,416 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ruby
def value(n : Int32, a : Array(Int32))
	idxes=Hash(Int32,Int32).new
	a.each_with_index{|e,i|idxes[e]=i}
	ret=0
	1.upto(n-1){|i|
		idxi=idxes[i]
		(i+1).upto(n){|j|
			idxj=idxes[j]
			r=0
			(0..n-1).each{|idxk|
				next if idxk==idxi || idxk==idxj
				b=[[idxi,a[idxi]],[idxj,a[idxj]],[idxk,a[idxk]]].sort
				if (b[0][1]<b[1][1]&&b[2][1]<b[1][1]) || (b[0][1]>b[1][1]&&b[2][1]>b[1][1])
					r=[r,a[idxk]].max
				end
			}
			ret+=[r,i,j].max if r>0
		}
	}
	ret
end
n,m=gets.not_nil!.split.map(&.to_i)
p (0..m-1).max_by{|i|value(n,gets.not_nil!.split.map(&.to_i))}
0