트리 배열+dp(잘 모름) Codeforces 597C

1554 단어
C. Subsequences
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed that the answer is not greater than 8·1018.
Input
First line contain two integer values n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 10) — the length of sequence and the number of elements in increasing subsequences.
Next n lines contains one integer ai (1 ≤ ai ≤ n) each — elements of sequence. All values ai are different.
Output
Print one integer — the answer to the problem.
Sample test(s)
input
5 2
1
2
3
5
4

output
7
 
           
          
#include
#include
#include
using namespace std;
long long n;
long long dp[12][100010];
long long query(long long x,long long i)
{
    long long ans=0;
    while(i>0)
    {
        ans+=dp[x][i];
        i-=i&-i;
    }
    return ans;
}
void update(long long x,long long i,long long num)
{
    while(i<=n)
    {
        dp[x][i]+=num;
        i+=i&-i;
    }
    return ;
}
int   main()
{
    long long  k;
    while(scanf("%lld%lld",&n,&k)!=EOF)
    {
        memset(dp,0,sizeof(dp));
        for(long long  i=0; i

좋은 웹페이지 즐겨찾기