結果
問題 | No.696 square1001 and Permutation 5 |
ユーザー | beet |
提出日時 | 2018-06-09 00:19:55 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 688 bytes |
コンパイル時間 | 377 ms |
コンパイル使用メモリ | 87,208 KB |
実行使用メモリ | 269,924 KB |
最終ジャッジ日時 | 2023-09-13 00:58:57 |
合計ジャッジ時間 | 34,460 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | AC | 67 ms
71,364 KB |
testcase_02 | AC | 71 ms
71,116 KB |
testcase_03 | AC | 74 ms
75,584 KB |
testcase_04 | AC | 74 ms
76,064 KB |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | AC | 3,450 ms
263,464 KB |
testcase_12 | AC | 66 ms
71,520 KB |
testcase_13 | AC | 66 ms
71,200 KB |
ソースコード
def main(): n = int(input()) p = list(map(int,input().split())) bit = list(map(int, [0 for i in range(n+1)])) def sum(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) ans = 1 buf = 0 x = 1 for i in range(1, n+1): t = x * sum(p[n-i]) buf = t + buf if i & 4095 == 0: ans = buf + ans buf = 0 add(p[n-i], 1) x = x * i print(ans + buf) main()