結果
問題 | No.694 square1001 and Permutation 3 |
ユーザー | ciel |
提出日時 | 2018-06-10 01:13:14 |
言語 | Ruby (3.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 363 bytes |
コンパイル時間 | 401 ms |
コンパイル使用メモリ | 11,248 KB |
実行使用メモリ | 48,368 KB |
最終ジャッジ日時 | 2023-09-13 02:30:58 |
合計ジャッジ時間 | 6,367 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 91 ms
27,584 KB |
testcase_01 | AC | 92 ms
22,984 KB |
testcase_02 | AC | 94 ms
22,944 KB |
testcase_03 | AC | 103 ms
23,120 KB |
testcase_04 | AC | 101 ms
23,084 KB |
testcase_05 | AC | 102 ms
22,988 KB |
testcase_06 | AC | 102 ms
23,176 KB |
testcase_07 | TLE | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
コンパイルメッセージ
Syntax OK
ソースコード
W=[0]*10**6 def bit(a,n) r=0 i=n-1 while i>=0 idx=a[i];(r+=W[idx];idx&=idx-1)while idx>0 idx=a[i];(W[idx]+=1;idx+=idx&-idx)while idx<=n i-=1 end r end n,*a=$<.map(&:to_i) z=(1..n).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| p x x-=((0...n).bsearch{|j|a[i]<=b[j]}||n)-n+((0...n).bsearch{|j|a[i]<b[j]}||n) }