結果

問題 No.1623 三角形の制作
ユーザー 小野寺健小野寺健
提出日時 2021-11-01 23:01:01
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 575 bytes
コンパイル時間 543 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 41,632 KB
最終ジャッジ日時 2024-04-18 22:46:40
合計ジャッジ時間 4,950 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
17,664 KB
testcase_01 AC 85 ms
12,160 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
r = gets.split(" ").map{|s| s.to_i}.sort
g = gets.split(" ").map{|s| s.to_i}.sort
b = gets.split(" ").map{|s| s.to_i}.sort

max = 3*10**3+1

cnt_r = Array.new(max, 0)
cnt_g = Array.new(max, 0)
cnt_b = Array.new(max, 0)

0.upto(n-1) {|i|
	cnt_r[r[i]] += 1
	cnt_g[g[i]] += 1
	cnt_b[b[i]] += 1
}

1.upto(max-1) {|i|
	cnt_r[i] += cnt_r[i-1]
	cnt_g[i] += cnt_g[i-1]
	cnt_b[i] += cnt_b[i-1]
}

cnt = 0
0.upto(n-1) {|i|
	a = r[i]
	rn = cnt_r[a] - cnt_r[a-1]
	1.upto(a) {|j|
		gn = cnt_g[j] - cnt_g[j-1]
		bn = cnt_b[a] - cnt_b[a-j]
		cnt += rn * gn * bn
	}
}

puts cnt
0