提出 #44621584


ソースコード 拡げる

class BIT
	def initialize n
		@n = n+1 # accessing 0..n-1, 1..n internally.
		@a = [0]*@n
	end

	def [] i
		i += 1
		s = 0
		while 0<i
			s += @a[i]
			i &= i-1
		end
		return s
	end
	def lb s
		i,t,b = 0,0,1<<(@n-1).bit_length
		t += @a[i|=b] if i|b<@n && t+@a[i|b]<s while 0<b >>= 1
		return i if i<@n-1 # i は1大きい内部インデックス(もしくは 0)だけど、求めた添字が s 未満の値を返す最大の添字であり、s の lower_bound としては +1 したものを返したいから、足し引きして内部インデックスそのままの値を返す(アクセス可能な範囲(0...@n-1)なら)。
	end

	def add i,d
		i += 1
		while i<@n
			@a[i] += d
			i += i&-i
		end
	end
	def inc i; add i,1 end
	def dec i; add i,-1 end
end

N,*S = $<.read.split.map(&:to_i)
S.sort!.reverse!
U = S.uniq
I = U.each_with_index.to_h
QS = BIT.new U.size
A = [S.shift]
S.each{|s|
	QS.inc I[s]
}

puts N.times.all?{|n|
	A.dup.all?{|a|
		if i = QS.lb(QS[I[a]]+1)
			QS.dec i
			A<<U[i]
		end
	}
}?'Yes':'No'

提出情報

提出日時
問題 F - Many Slimes
ユーザ ds14050
言語 Ruby (2.7.1)
得点 600
コード長 1076 Byte
結果 AC
実行時間 1108 ms
メモリ 56404 KiB

ジャッジ結果

セット名 All Sample
得点 / 配点 600 / 600 0 / 0
結果
AC × 79
AC × 4
セット名 テストケース
All sample_01, sample_02, sample_03, sample_04, testcase_0, testcase_1, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15, testcase_16, testcase_17, testcase_18, testcase_19, testcase_2, testcase_20, testcase_21, testcase_22, testcase_23, testcase_24, testcase_25, testcase_26, testcase_27, testcase_28, testcase_29, testcase_3, testcase_30, testcase_31, testcase_32, testcase_33, testcase_34, testcase_35, testcase_36, testcase_37, testcase_38, testcase_39, testcase_4, testcase_40, testcase_41, testcase_42, testcase_43, testcase_44, testcase_45, testcase_46, testcase_47, testcase_48, testcase_49, testcase_5, testcase_50, testcase_51, testcase_52, testcase_53, testcase_54, testcase_55, testcase_56, testcase_57, testcase_58, testcase_59, testcase_6, testcase_60, testcase_61, testcase_62, testcase_63, testcase_64, testcase_65, testcase_66, testcase_67, testcase_68, testcase_69, testcase_7, testcase_70, testcase_71, testcase_72, testcase_73, testcase_74, testcase_8, testcase_9
Sample sample_01, sample_02, sample_03, sample_04
ケース名 結果 実行時間 メモリ
sample_01 AC 57 ms 14224 KiB
sample_02 AC 55 ms 14088 KiB
sample_03 AC 55 ms 14148 KiB
sample_04 AC 56 ms 14304 KiB
testcase_0 AC 59 ms 14224 KiB
testcase_1 AC 58 ms 14276 KiB
testcase_10 AC 437 ms 40124 KiB
testcase_11 AC 55 ms 14232 KiB
testcase_12 AC 57 ms 14044 KiB
testcase_13 AC 55 ms 14336 KiB
testcase_14 AC 263 ms 27328 KiB
testcase_15 AC 56 ms 14196 KiB
testcase_16 AC 54 ms 14168 KiB
testcase_17 AC 453 ms 40196 KiB
testcase_18 AC 57 ms 14128 KiB
testcase_19 AC 58 ms 14204 KiB
testcase_2 AC 408 ms 32740 KiB
testcase_20 AC 154 ms 20360 KiB
testcase_21 AC 440 ms 40172 KiB
testcase_22 AC 67 ms 14708 KiB
testcase_23 AC 449 ms 40100 KiB
testcase_24 AC 151 ms 20188 KiB
testcase_25 AC 55 ms 14296 KiB
testcase_26 AC 68 ms 14728 KiB
testcase_27 AC 60 ms 14096 KiB
testcase_28 AC 61 ms 14176 KiB
testcase_29 AC 57 ms 14032 KiB
testcase_3 AC 453 ms 32168 KiB
testcase_30 AC 57 ms 14184 KiB
testcase_31 AC 1069 ms 55104 KiB
testcase_32 AC 1061 ms 56256 KiB
testcase_33 AC 1065 ms 56404 KiB
testcase_34 AC 1048 ms 55000 KiB
testcase_35 AC 1052 ms 56188 KiB
testcase_36 AC 159 ms 19548 KiB
testcase_37 AC 57 ms 14264 KiB
testcase_38 AC 57 ms 14184 KiB
testcase_39 AC 57 ms 14044 KiB
testcase_4 AC 821 ms 50452 KiB
testcase_40 AC 160 ms 19696 KiB
testcase_41 AC 275 ms 25100 KiB
testcase_42 AC 61 ms 14116 KiB
testcase_43 AC 1062 ms 55168 KiB
testcase_44 AC 57 ms 14212 KiB
testcase_45 AC 107 ms 16872 KiB
testcase_46 AC 966 ms 48876 KiB
testcase_47 AC 57 ms 14132 KiB
testcase_48 AC 58 ms 14144 KiB
testcase_49 AC 59 ms 14132 KiB
testcase_5 AC 892 ms 48280 KiB
testcase_50 AC 148 ms 18460 KiB
testcase_51 AC 56 ms 14192 KiB
testcase_52 AC 61 ms 14388 KiB
testcase_53 AC 57 ms 14120 KiB
testcase_54 AC 109 ms 16972 KiB
testcase_55 AC 58 ms 14300 KiB
testcase_56 AC 56 ms 14088 KiB
testcase_57 AC 87 ms 15524 KiB
testcase_58 AC 58 ms 14144 KiB
testcase_59 AC 1069 ms 55100 KiB
testcase_6 AC 1108 ms 55168 KiB
testcase_60 AC 57 ms 14136 KiB
testcase_61 AC 56 ms 13948 KiB
testcase_62 AC 58 ms 14180 KiB
testcase_63 AC 55 ms 14072 KiB
testcase_64 AC 57 ms 14028 KiB
testcase_65 AC 57 ms 13956 KiB
testcase_66 AC 56 ms 14320 KiB
testcase_67 AC 57 ms 14108 KiB
testcase_68 AC 57 ms 14200 KiB
testcase_69 AC 56 ms 14148 KiB
testcase_7 AC 451 ms 40232 KiB
testcase_70 AC 56 ms 14176 KiB
testcase_71 AC 59 ms 14128 KiB
testcase_72 AC 56 ms 14292 KiB
testcase_73 AC 57 ms 14168 KiB
testcase_74 AC 56 ms 13980 KiB
testcase_8 AC 447 ms 40160 KiB
testcase_9 AC 437 ms 40088 KiB