結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
16,324 KB
testcase_01 AC 205 ms
17,380 KB
testcase_02 AC 232 ms
17,580 KB
testcase_03 AC 175 ms
17,036 KB
testcase_04 AC 210 ms
17,456 KB
testcase_05 AC 886 ms
27,304 KB
testcase_06 AC 737 ms
25,776 KB
testcase_07 AC 678 ms
25,332 KB
testcase_08 AC 643 ms
24,936 KB
testcase_09 AC 596 ms
24,676 KB
testcase_10 AC 494 ms
24,292 KB
testcase_11 AC 895 ms
27,440 KB
testcase_12 AC 749 ms
25,780 KB
testcase_13 AC 706 ms
25,336 KB
testcase_14 AC 641 ms
24,932 KB
testcase_15 AC 604 ms
24,672 KB
testcase_16 AC 484 ms
24,360 KB
testcase_17 AC 709 ms
25,352 KB
testcase_18 AC 711 ms
25,320 KB
testcase_19 AC 693 ms
25,288 KB
testcase_20 AC 493 ms
23,860 KB
testcase_21 AC 83 ms
15,488 KB
testcase_22 AC 82 ms
15,236 KB
testcase_23 AC 82 ms
15,280 KB
testcase_24 AC 81 ms
15,356 KB
testcase_25 AC 83 ms
15,356 KB
testcase_26 AC 81 ms
15,300 KB
testcase_27 AC 82 ms
15,236 KB
testcase_28 AC 81 ms
15,416 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