QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#232857 | #6410. Classical DP Problem | bianca | WA | 0ms | 3624kb | C++14 | 1.3kb | 2023-10-30 23:46:48 | 2023-10-30 23:46:48 |
Judging History
answer
#include <iostream>
#include <algorithm>
using namespace std;
#define MaxN 5001
#define MOD 998244353
int a[MaxN], b[MaxN];
int dp[MaxN][MaxN];
int dinamic(int a[], int k, int x)
{
dp[0][x]=1;
int i, j;
for(i=0; i<k; i++)
{
for(j=x; j>=0; j--)
{
dp[i+1][j]+=(a[i+1]-j)*dp[i][j];
dp[i+1][j]%=MOD;
if(j>0)
{
dp[i+1][j-1]+=j*dp[i][j];
dp[i+1][j-1]%=MOD;
}
}
}
return dp[k][0];
}
int fact(int k)
{
int prod=1;
while(k>0)
{
prod=prod*k;
prod%=MOD;
k--;
}
}
int main()
{
int n, i, j, k, x=0, res;
cin>>n;
for(i=1; i<=n; i++)
{
cin>>a[i];
}
k=1;
while(n-k>a[k])
{
k++;
}
cout<<k<<" ";
reverse(a+1, a+n+1);
/* x=a[k+1];
res+=dinamic(a, k, x);
for(i=n; i>0; i--)
{
j=1;
while(a[j]>=i)
{
j++;
}
b[i]=j-1;
}
x=b[k+1];
for(i=0; i<=n; i++)
{
for(j=0; j<=n; j++)
{
dp[i][j]=0;
}
}
res+=dinamic(b, k, x);
res%=MOD;
res-=fact(k);
cout<<res;*/
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3624kb
input:
3 1 2 3
output:
2
result:
wrong answer Answer contains longer sequence [length = 2], but output contains 1 elements