結果
問題 | No.694 square1001 and Permutation 3 |
ユーザー | ciel |
提出日時 | 2018-12-04 13:04:40 |
言語 | Ruby (3.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 362 bytes |
コンパイル時間 | 260 ms |
コンパイル使用メモリ | 11,432 KB |
実行使用メモリ | 44,592 KB |
最終ジャッジ日時 | 2023-09-21 10:25:35 |
合計ジャッジ時間 | 7,607 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 85 ms
23,728 KB |
testcase_01 | AC | 85 ms
19,476 KB |
testcase_02 | AC | 84 ms
19,408 KB |
testcase_03 | AC | 94 ms
19,500 KB |
testcase_04 | AC | 93 ms
19,268 KB |
testcase_05 | AC | 93 ms
19,268 KB |
testcase_06 | AC | 92 ms
19,372 KB |
testcase_07 | TLE | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
コンパイルメッセージ
Syntax OK
ソースコード
W=[0]*9**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) }