結果
問題 |
No.165 四角で囲え!
|
ユーザー |
|
提出日時 | 2015-03-13 11:47:01 |
言語 | Ruby (3.4.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 495 bytes |
コンパイル時間 | 312 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 59,428 KB |
最終ジャッジ日時 | 2024-06-28 22:50:26 |
合計ジャッジ時間 | 12,487 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 4 |
other | TLE * 1 -- * 18 |
コンパイルメッセージ
Syntax OK
ソースコード
def g;gets.split.map(&:to_i)end n,b=g mx=Hash.new{[]} my=Hash.new{[]} m=(0...n).map{|i| x,y,q=g mx[x]+=[i] my[y]+=[i] [x,y,q] } def cum a Hash[a.inject([[0,[]]]){|s,(k,v)|s+[[k,s[-1][1]+v]]}[1..-1]] end sxa=cum mx.sort sxb=cum mx.sort.reverse sya=cum my.sort syb=cum my.sort.reverse p mx.keys.sort.repeated_combination(2).map{|xi,xj| my.keys.sort.repeated_combination(2).map{|yi,yj| t=sxb[xi]&sxa[xj]&syb[yi]&sya[yj] b<(t.map{|k|m[k][2]}.inject(:+)||0)?0:t.size }.max }.max