結果

問題 No.1623 三角形の制作
ユーザー 小野寺健小野寺健
提出日時 2021-11-01 23:09:51
言語 Ruby
(3.3.0)
結果
AC  
実行時間 990 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 38,144 KB
最終ジャッジ日時 2024-04-18 22:57:36
合計ジャッジ時間 13,074 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
12,160 KB
testcase_01 AC 81 ms
12,032 KB
testcase_02 AC 868 ms
34,688 KB
testcase_03 AC 835 ms
34,048 KB
testcase_04 AC 837 ms
34,176 KB
testcase_05 AC 990 ms
36,604 KB
testcase_06 AC 731 ms
16,384 KB
testcase_07 AC 828 ms
34,304 KB
testcase_08 AC 711 ms
17,152 KB
testcase_09 AC 805 ms
33,408 KB
testcase_10 AC 931 ms
37,632 KB
testcase_11 AC 884 ms
34,560 KB
testcase_12 AC 171 ms
24,448 KB
testcase_13 AC 191 ms
24,960 KB
testcase_14 AC 182 ms
24,576 KB
testcase_15 AC 335 ms
36,284 KB
testcase_16 AC 329 ms
36,132 KB
testcase_17 AC 334 ms
36,380 KB
testcase_18 AC 336 ms
38,144 KB
testcase_19 AC 223 ms
34,176 KB
testcase_20 AC 85 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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
1.upto(max-1) {|a|
	next if cnt_r[a] == cnt_r[a-1]
	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