結果

問題 No.694 square1001 and Permutation 3
ユーザー cielciel
提出日時 2018-06-10 01:20:04
言語 Crystal
(1.11.2)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 408 bytes
コンパイル時間 20,319 ms
コンパイル使用メモリ 259,648 KB
実行使用メモリ 17,052 KB
最終ジャッジ日時 2023-09-13 09:44:50
合計ジャッジ時間 29,405 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

W=[0]*10**6
def bit(a,n)
	r=0_i64
	i=n-1
	while i>=0
		idx=a[i];while idx>0;r+=W[idx];idx&=idx-1 end
		idx=a[i];while idx<=n;W[idx]+=1;idx+=idx&-idx end
		i-=1
	end
	r
end
a=ARGF.gets_to_end.split.map(&.to_i)
n=a.shift
z=(1..n).to_a.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|
	puts x
	x-=((0...n).bsearch{|j|a[i]<=b[j]}||n)-n+((0...n).bsearch{|j|a[i]<b[j]}||n)
}
0