結果
| 問題 |
No.2665 Minimize Inversions of Deque
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2023-12-30 10:10:59 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 1,069 ms / 2,000 ms |
| コード長 | 399 bytes |
| コンパイル時間 | 325 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 29,960 KB |
| 最終ジャッジ日時 | 2024-09-27 19:06:57 |
| 合計ジャッジ時間 | 23,947 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 40 |
ソースコード
I,O,R=input,print,range def A(i,t): i+=1 while i<=N:F[i],i=F[i]+t,i+(i&-i) def L(r): a=0 i=min(r+1,N) while i:a,i=a+F[i],i-(i&-i) return a for t in R(int(I())): N,a,X,Y=int(I()),0,[],[] P,F=list(map(int,I().split())),[0]*(N+1) for i,p in zip(R(N),P): c=L(p) if c<i-c or not(X or Y)or(i==2*c and X[-1]>p): a+=c X+=[p] else: a+=i-c Y+=[p] A(p,1) X.reverse(),O(a),O(*X,*Y)