結果
問題 | No.694 square1001 and Permutation 3 |
ユーザー |
|
提出日時 | 2018-12-04 14:19:53 |
言語 | Crystal (1.14.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 329 bytes |
コンパイル時間 | 15,885 ms |
コンパイル使用メモリ | 301,936 KB |
実行使用メモリ | 37,760 KB |
最終ジャッジ日時 | 2024-06-30 19:38:54 |
合計ジャッジ時間 | 18,534 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 1 |
other | WA * 7 TLE * 1 -- * 5 |
ソースコード
W=[0]*9**6a=ARGF.gets_to_end.split.map &.to_ii=n=a.shiftz=(0...n).to_a.sort{|i,j|a[i]!=a[j] ? a[i]<=>a[j]: i<=>j}r=0_i64b=a.sortwhile 0<=(i-=1)k=z[i];while k>0;r+=W[k];k-=-k&k;p k endk=z[i]+1;while k<=n;W[k]+=1;k+=-k&k endendn.times{|i|puts r;r-=((0...n).bsearch{|j|a[i]<=b[j]}||n)-n+((0...n).bsearch{|j|a[i]<b[j]}||n)}