結果
問題 | No.694 square1001 and Permutation 3 |
ユーザー |
|
提出日時 | 2018-06-10 01:26:42 |
言語 | Crystal (1.14.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 332 bytes |
コンパイル時間 | 13,154 ms |
コンパイル使用メモリ | 299,956 KB |
実行使用メモリ | 44,676 KB |
最終ジャッジ日時 | 2024-06-30 19:28:49 |
合計ジャッジ時間 | 47,736 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | TLE * 1 |
other | RE * 5 TLE * 8 |
ソースコード
W=[0]*9**6 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} r=0_i64 i=n while 0<=(i-=1) k=a[i];while k>0;r+=W[k];k&=k-1 end k=a[i];while k<=n;W[k]+=1;k+=k&-k end end b=a.sort 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)}