結果

問題 No.318 学学学学学
ユーザー koyumeishikoyumeishi
提出日時 2015-12-11 02:13:40
言語 Ruby
(3.3.0)
結果
AC  
実行時間 899 ms / 2,000 ms
コード長 1,429 bytes
コンパイル時間 126 ms
コンパイル使用メモリ 11,516 KB
実行使用メモリ 27,424 KB
最終ジャッジ日時 2023-09-04 17:11:19
合計ジャッジ時間 15,994 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
16,288 KB
testcase_01 AC 207 ms
17,384 KB
testcase_02 AC 235 ms
17,676 KB
testcase_03 AC 179 ms
17,088 KB
testcase_04 AC 211 ms
17,560 KB
testcase_05 AC 896 ms
27,364 KB
testcase_06 AC 743 ms
25,764 KB
testcase_07 AC 693 ms
25,212 KB
testcase_08 AC 650 ms
24,920 KB
testcase_09 AC 606 ms
24,628 KB
testcase_10 AC 502 ms
24,248 KB
testcase_11 AC 899 ms
27,424 KB
testcase_12 AC 757 ms
25,860 KB
testcase_13 AC 710 ms
25,416 KB
testcase_14 AC 651 ms
24,892 KB
testcase_15 AC 600 ms
24,680 KB
testcase_16 AC 486 ms
24,336 KB
testcase_17 AC 714 ms
25,420 KB
testcase_18 AC 727 ms
25,460 KB
testcase_19 AC 715 ms
25,392 KB
testcase_20 AC 510 ms
23,812 KB
testcase_21 AC 90 ms
15,400 KB
testcase_22 AC 91 ms
15,388 KB
testcase_23 AC 91 ms
15,220 KB
testcase_24 AC 91 ms
15,456 KB
testcase_25 AC 91 ms
15,252 KB
testcase_26 AC 91 ms
15,336 KB
testcase_27 AC 89 ms
15,424 KB
testcase_28 AC 90 ms
15,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#coding = utf-8
require "set"

💩 = gets.to_i;
💩💩 = gets.split().map(&:to_i);

💩💩💩💩 = 💩💩.sort().uniq()

👾 = 💩💩💩💩.size;

for 🚽 in 0...💩 do
	👇 = -1;
	👆 = 👾-1;
	while (👆-👇>1) do
		💪 = (👇+👆)/2;
		if 💩💩[🚽] <= 💩💩💩💩[💪] then
			👆 = 💪;
		else
			👇 = 💪;
		end
	end
	💩💩[🚽] = 👆;
end

🐕💩 = Array.new(👾);
🐈💩 = Array.new(👾);

0.upto(💩-1) { |🚽|
	🐕💩[ 💩💩[🚽] ] = 🚽;
}

(💩-1).downto(0) { |🚽|
	🐈💩[ 💩💩[🚽] ] = 🚽;
}

$👉💩 = Array.new(👾+5, 0);
$💩👈 = 👾;
def add(i,x)
	i+=1;
	while(i<=$💩👈) do
		$👉💩[i] += x;
		i += i&-i;
	end
end

def get_sum(i)
	i+=1;
	ret = 0;
	while(i>0) do
		ret += $👉💩[i];
		i -= i&-i;
	end
	return ret;
end

def lower_bound(v)
	if (v<=0) then
		return 0;
	end
	x = 0;
	k = 1;
	while (k<<1) <= $💩👈 do
		k<<=1;
	end
	while k>0 do
		if(x+k<=$💩👈 && $👉💩[x+k] < v) then
			v -= $👉💩[x+k];
			x += k;
		end
		k >>= 1;
	end
	return x+1;
end

🎅 = Array.new(💩, "🎅");
contain_💩 = 0;

0.upto(💩-1) { |🚽|
	if 🐈💩[ 💩💩[🚽] ] == 🚽 then
		add(💩💩[🚽], 1);
		contain_💩 += 1;
	end
	
	🎅[🚽] = 💩💩💩💩[lower_bound(contain_💩)-1];
	
	if 🐕💩[ 💩💩[🚽] ] == 🚽 then
		add(💩💩[🚽], -1);
		contain_💩 -= 1;
	end
}


puts 🎅.join(" ")
0