結果
問題 | No.2029 Swap Min Max Min |
ユーザー | tamato |
提出日時 | 2022-08-05 21:37:24 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,350 bytes |
コンパイル時間 | 1,835 ms |
コンパイル使用メモリ | 86,996 KB |
実行使用メモリ | 111,372 KB |
最終ジャッジ日時 | 2023-10-14 00:04:40 |
合計ジャッジ時間 | 9,546 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
70,912 KB |
testcase_01 | AC | 73 ms
71,048 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 122 ms
90,408 KB |
testcase_06 | AC | 160 ms
107,392 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 106 ms
82,784 KB |
testcase_11 | WA | - |
testcase_12 | AC | 134 ms
95,264 KB |
testcase_13 | WA | - |
testcase_14 | AC | 189 ms
105,832 KB |
testcase_15 | WA | - |
testcase_16 | AC | 188 ms
105,576 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 185 ms
105,612 KB |
testcase_20 | AC | 186 ms
105,660 KB |
testcase_21 | AC | 189 ms
105,604 KB |
testcase_22 | AC | 186 ms
105,916 KB |
testcase_23 | WA | - |
testcase_24 | AC | 182 ms
105,940 KB |
testcase_25 | AC | 187 ms
105,700 KB |
testcase_26 | AC | 189 ms
105,880 KB |
testcase_27 | WA | - |
testcase_28 | AC | 81 ms
75,680 KB |
testcase_29 | AC | 73 ms
71,204 KB |
testcase_30 | AC | 78 ms
75,416 KB |
testcase_31 | AC | 82 ms
75,540 KB |
testcase_32 | WA | - |
testcase_33 | AC | 74 ms
71,448 KB |
testcase_34 | WA | - |
testcase_35 | AC | 75 ms
71,412 KB |
testcase_36 | AC | 73 ms
71,124 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | AC | 184 ms
106,096 KB |
testcase_40 | AC | 175 ms
111,372 KB |
testcase_41 | AC | 177 ms
108,656 KB |
testcase_42 | AC | 178 ms
108,340 KB |
testcase_43 | AC | 183 ms
105,536 KB |
testcase_44 | AC | 186 ms
105,688 KB |
ソースコード
mod = 998244353 def main(): import sys input = sys.stdin.readline class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x i += i & -i def lower_bound(self, w): if w <= 0: return 0 x = 0 k = 1 << (self.size.bit_length() - 1) while k: if x + k <= self.size and self.tree[x + k] < w: w -= self.tree[x + k] x += k k >>= 1 return x + 1 N = int(input()) A = list(map(int, input().split())) X = N // 2 C = [] cnt0 = cnt1 = 0 for a in A: if a <= X: C.append(2 + cnt1 * 2) cnt1 += 1 else: C.append(1 + cnt0 * 2) cnt0 += 1 bit = Bit(N) idx = [0] * (N + 1) for i, c in enumerate(C): idx[c] = i + 1 Y = 0 for x in range(N, 0, -1): i = idx[x] Y += bit.sum(i) bit.add(i, 1) print(X, Y) if __name__ == '__main__': main()