結果
| 問題 |
No.694 square1001 and Permutation 3
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-10 01:20:04 |
| 言語 | Crystal (1.14.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 408 bytes |
| コンパイル時間 | 16,232 ms |
| コンパイル使用メモリ | 301,256 KB |
| 実行使用メモリ | 48,276 KB |
| 最終ジャッジ日時 | 2024-06-30 19:31:10 |
| 合計ジャッジ時間 | 66,074 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 1 |
| other | TLE * 13 |
ソースコード
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)
}