結果

問題 No.694 square1001 and Permutation 3
ユーザー cielciel
提出日時 2018-06-10 01:03:20
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 362 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 11,472 KB
実行使用メモリ 48,200 KB
最終ジャッジ日時 2023-09-13 02:29:10
合計ジャッジ時間 6,598 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
23,280 KB
testcase_01 AC 83 ms
23,096 KB
testcase_02 AC 85 ms
22,912 KB
testcase_03 WA -
testcase_04 AC 93 ms
22,984 KB
testcase_05 WA -
testcase_06 AC 95 ms
23,056 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

W=[0]*10**6
def bit(a,n)
	r=0
	i=n-1
	while i>=0
		idx=a[i];(r+=W[idx];idx&=idx-1)while idx>0
		idx=a[i];(W[idx]+=1;idx+=idx&-idx)while idx<n
		i-=1
	end
	r
end
n,*a=$<.map(&:to_i)
z=(1..n).sort{|i,j|a[i-1]!=a[j-1] ? a[i-1]<=>a[j-1] : i<=>j}
x=bit(z,z.size)
b=a.sort
n.times{|i|
	p x
	x-=((0...n).bsearch{|j|a[i]<=b[j]}||n)-n+((0...n).bsearch{|j|a[i]<b[j]}||n)
}
0