結果

問題 No.694 square1001 and Permutation 3
ユーザー cielciel
提出日時 2018-12-04 14:20:40
言語 Crystal
(1.11.2)
結果
AC  
実行時間 1,180 ms / 3,000 ms
コード長 325 bytes
コンパイル時間 21,900 ms
コンパイル使用メモリ 260,620 KB
実行使用メモリ 47,920 KB
最終ジャッジ日時 2023-09-13 09:55:03
合計ジャッジ時間 31,085 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,652 KB
testcase_01 AC 4 ms
6,564 KB
testcase_02 AC 4 ms
6,360 KB
testcase_03 AC 5 ms
6,700 KB
testcase_04 AC 5 ms
6,612 KB
testcase_05 AC 4 ms
6,548 KB
testcase_06 AC 5 ms
6,568 KB
testcase_07 AC 883 ms
34,168 KB
testcase_08 AC 1,173 ms
42,328 KB
testcase_09 AC 1,169 ms
47,580 KB
testcase_10 AC 758 ms
34,100 KB
testcase_11 AC 1,180 ms
47,852 KB
testcase_12 AC 1,176 ms
47,920 KB
testcase_13 AC 5 ms
6,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

W=[0]*9**6
a=ARGF.gets_to_end.split.map &.to_i
i=n=a.shift
z=(0...n).to_a.sort{|i,j|a[i]!=a[j] ? a[i]<=>a[j]: i<=>j}
r=0_i64
b=a.sort
while 0<=(i-=1)
k=z[i];while k>0;r+=W[k];k-=-k&k end
k=z[i]+1;while k<=n;W[k]+=1;k+=-k&k end
end
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