結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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]*9**6
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}
r=0_i64
i=n
while 0<=(i-=1)
k=z[i];while k>0;r+=W[k];k&=k-1 end
k=z[i];while k<=n;W[k]+=1;k+=k&-k end
end
b=a.sort
n.times{|i|puts r;r-=((0...n).bsearch{|j|a[i]<=b[j]}||n)-n+((0...n).bsearch{|j|a[i]<b[j]}||n)}
0