結果
問題 | No.742 にゃんにゃんにゃん 猫の挨拶 |
ユーザー |
|
提出日時 | 2022-06-10 05:28:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 79 ms / 2,500 ms |
コード長 | 842 bytes |
コンパイル時間 | 178 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 78,336 KB |
最終ジャッジ日時 | 2024-09-21 05:41:40 |
合計ジャッジ時間 | 1,912 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
ソースコード
# import pypyjit# pypyjit.set_param('max_unroll_recursion=-1')import sysfrom itertools import combinations, permutations, product, accumulate, groupbyfrom collections import defaultdict, deque, Counterfrom functools import reducefrom operator import add, mulimport heapqimport bisectimport mathimport copysys.setrecursionlimit(10 ** 9)input = lambda: sys.stdin.readline().rstrip()INF = float("inf")MOD = 10 ** 9 + 7N = int(input())A = []for i in range(N):A.append(int(input()))# BITdata = [0]*(N+1)def add(k, x):while k <= N:data[k] += xk += k & -kdef get(k):s = 0while k:s += data[k]k -= k & -kreturn sans = 0for i, a in enumerate(A):# 自分より小さい要素がいくつ存在するかを計算ans += (N-1-i) - get(a)add(a, 1)print(ans)