ps | |
---|---|
링크 | acmicpc.net/… |
출처 | BOJ |
문제 번호 | 24505 |
문제명 | blobhyperthink |
레벨 | 플래티넘 4 |
분류 |
구간쿼리 |
시간복잡도 | O(nlogn) |
인풋사이즈 | n<=10^5 |
사용한 언어 | Python 3.11 |
제출기록 | 52812KB / 3088ms |
최고기록 | 2952ms |
해결날짜 | 2023/08/04 |
"""Solution code for "BOJ 24505. blobhyperthink".
- Problem link: https://www.acmicpc.net/problem/24505
- Solution link: http://www.teferi.net/ps/problems/boj/24505
Tags: [segment tree]
"""
import sys
from teflib import fenwicktree
MOD = 10**9 + 7
def main():
N = int(sys.stdin.readline())
A = [int(x) for x in sys.stdin.readline().split()]
cur_counts = [1] * N
for _ in range(10):
cur_counts, prev_counts = [0] * N, cur_counts
ost = fenwicktree.OrderStatisticTree(N + 1)
for i, a_i in enumerate(A):
cur_counts[i] = ost.count_less_than(a_i) % MOD
ost.add(a_i, prev_counts[i])
print(sum(cur_counts) % MOD)
if __name__ == '__main__':
main()