結果

問題 No.694 square1001 and Permutation 3
ユーザー cielciel
提出日時 2018-12-04 14:19:53
言語 Crystal
(1.11.2)
結果
WA  
実行時間 -
コード長 329 bytes
コンパイル時間 18,216 ms
コンパイル使用メモリ 260,556 KB
実行使用メモリ 6,664 KB
最終ジャッジ日時 2023-09-13 09:53:45
合計ジャッジ時間 24,446 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 OLE -
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
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;p 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