把数组离散化后,用树状数组维护某个值结尾的符合要求的子序列数量,枚举每一个数组中的数,查询比他大的结尾的子序列个数sum,ans+=sum+1(1是他本身),add(id,sum+1)即可
#include <bits/stdc++.h>
using namespace std;
小红有一个长度为n的数组a1,a2,...,an,请你帮助他求出有多少个严格单调递减的子序列。结果可能很大,对109+7取模后在输出。
By signing up a CodeFun2000 universal account, you can submit code and join discussions in all online judging services provided by us.