結果
| 問題 |
No.696 square1001 and Permutation 5
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2018-06-09 00:25:45 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 679 bytes |
| コンパイル時間 | 158 ms |
| コンパイル使用メモリ | 82,088 KB |
| 実行使用メモリ | 848,944 KB |
| 最終ジャッジ日時 | 2024-06-30 12:02:30 |
| 合計ジャッジ時間 | 21,269 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | MLE * 1 -- * 11 |
ソースコード
def main():
n = int(input())
p = list(map(int,input().split()))
bit = list(map(int, [0 for i in range(n+1)]))
def get(x):
res = 0
while x > 0:
res = res + bit[x]
x = x - (x&-x)
return res
def add(x, y):
if(x == 0):
return
while x <= n:
bit[x] = bit[x] + y
x = x + (x&-x)
buf = list(map(int, [0 for i in range(1024)]))
a = 1
for i in range(1, n+1):
t = a * get(p[n-i])
buf[i&1023] = t + buf[i&1023]
add(p[n-i], 1)
a = a * i
ans = 1 + sum(buf)
print(ans)
main()
beet