結果

問題 No.318 学学学学学
ユーザー koyumeishikoyumeishi
提出日時 2015-12-11 02:19:00
言語 Ruby
(3.1.1p18 )
結果
AC  
実行時間 945 ms / 2,000 ms
コード長 1,692 bytes
コンパイル時間 32 ms
使用メモリ 27,916 KB
最終ジャッジ日時 2023-01-19 23:05:06
合計ジャッジ時間 15,146 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 139 ms
15,600 KB
testcase_01 AC 210 ms
16,276 KB
testcase_02 AC 239 ms
17,772 KB
testcase_03 AC 178 ms
16,008 KB
testcase_04 AC 212 ms
17,164 KB
testcase_05 AC 927 ms
27,900 KB
testcase_06 AC 752 ms
26,296 KB
testcase_07 AC 702 ms
25,832 KB
testcase_08 AC 669 ms
25,380 KB
testcase_09 AC 618 ms
25,292 KB
testcase_10 AC 520 ms
24,904 KB
testcase_11 AC 945 ms
27,916 KB
testcase_12 AC 779 ms
26,424 KB
testcase_13 AC 731 ms
25,956 KB
testcase_14 AC 668 ms
25,416 KB
testcase_15 AC 617 ms
25,064 KB
testcase_16 AC 499 ms
24,792 KB
testcase_17 AC 742 ms
25,768 KB
testcase_18 AC 755 ms
25,852 KB
testcase_19 AC 725 ms
25,752 KB
testcase_20 AC 523 ms
24,244 KB
testcase_21 AC 76 ms
14,136 KB
testcase_22 AC 78 ms
14,184 KB
testcase_23 AC 77 ms
14,472 KB
testcase_24 AC 77 ms
14,132 KB
testcase_25 AC 78 ms
14,136 KB
testcase_26 AC 78 ms
14,380 KB
testcase_27 AC 78 ms
14,140 KB
testcase_28 AC 77 ms
14,356 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 うんこ(🐦💩,x)
	🐦💩+=1;
	while(🐦💩<=$💩👈) do
		$👉💩[🐦💩] += x;
		🐦💩 += 🐦💩&-🐦💩;
	end
end

def 💩_bound(💩💩💩💩💩)
	if (💩💩💩💩💩<=0) then
		return 0;
	end
	___💩💩💩 = 0;
	_____💩💩💩 = 1;
	while (_____💩💩💩<<1) <= $💩👈 do
		_____💩💩💩<<=1;
	end
	while _____💩💩💩>0 do
		if(___💩💩💩+_____💩💩💩<=$💩👈 && $👉💩[___💩💩💩+_____💩💩💩] < 💩💩💩💩💩) then
			💩💩💩💩💩 -= $👉💩[___💩💩💩+_____💩💩💩];
			___💩💩💩 += _____💩💩💩;
		end
		_____💩💩💩 >>= 1;
	end
	return ___💩💩💩+1;
end

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

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


puts 🎅.join(" ")
0