結果

問題 No.989 N×Mマス計算(K以上)
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-02-09 03:35:00
言語 Ruby
(3.3.0)
結果
AC  
実行時間 366 ms / 2,000 ms
コード長 409 bytes
コンパイル時間 117 ms
コンパイル使用メモリ 11,444 KB
実行使用メモリ 26,980 KB
最終ジャッジ日時 2023-09-20 15:44:40
合計ジャッジ時間 5,105 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,256 KB
testcase_01 AC 83 ms
15,292 KB
testcase_02 AC 83 ms
15,236 KB
testcase_03 AC 82 ms
15,120 KB
testcase_04 AC 82 ms
15,084 KB
testcase_05 AC 83 ms
15,164 KB
testcase_06 AC 82 ms
15,160 KB
testcase_07 AC 83 ms
15,120 KB
testcase_08 AC 83 ms
15,252 KB
testcase_09 AC 82 ms
15,120 KB
testcase_10 AC 249 ms
22,288 KB
testcase_11 AC 289 ms
25,072 KB
testcase_12 AC 287 ms
23,928 KB
testcase_13 AC 224 ms
23,532 KB
testcase_14 AC 366 ms
26,980 KB
testcase_15 AC 154 ms
18,000 KB
testcase_16 AC 214 ms
20,188 KB
testcase_17 AC 221 ms
23,508 KB
testcase_18 AC 143 ms
17,328 KB
testcase_19 AC 297 ms
25,140 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - m
Main.rb:6: warning: assigned but unused variable - c1
Syntax OK

ソースコード

diff #

bhs={}
as=[]
n,m,k=gets.split(" ").map{|e| e.to_i}
bs=gets.chomp.split(" ")
op=bs.shift
c1=1
bs.map{|e| e.to_i}.sort.reverse.each{|b|
	bhs[b]=0 if bhs.member?(b)==false
	bhs[b]+=1
}
n.times{
	as<<gets.to_i
}
as.sort!
p2=0
ans=0
bhs.sort.reverse.each{|k1,v1|
	k2=0
	if op=="+" then
		k2=k-k1
	else
		k2=k/k1+((k%k1==0)?(0):(1))
	end
	while p2<n && as[p2]<k2 do
		p2+=1
	end
	v2=n-p2
	ans=ans+(v1*v2)
}
puts ans
0