This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n;
cin>>n;
vector<int>v(n);
for(int i=0;i<n;i++)
cin>>v[i];
int dp[n][n+5];
memset(dp,0,sizeof(dp));
for(int i=1;i<=n;i++)
dp[n-1][i]=i-1;
for(int i=n-2;i>=0;i--){
for(int j=2;j<=n;j++){
dp[i][j]=dp[i][j-1];
for(int k=i+1;k<n;k++){
dp[i][j]+=dp[k][j-1+(k-(i))];
}
dp[i][j]++;
}
}
/***
for(int i=0;i<n;i++){
for(int j=1;j<=n;j++)
cout<<dp[i][j]<<' ';
cout<<'\n';
}*/
int ans=0;
for(int i=0;i<n;i++)
ans+=dp[i][v[i]];
cout<<ans+1<<'\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |