Submission #146738

# Submission time Handle Problem Language Result Execution time Memory
146738 2019-08-25T19:12:49 Z vex Calvinball championship (CEOI15_teams) C++14
10 / 100
9 ms 7288 KB
#include<bits/stdc++.h>
#define maxn 1005
#define mod 1000007
#define ll long long
using namespace std;

int n;
int a[maxn];
ll dp[maxn][maxn];
int g[maxn];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    g[1]=1;
    for(int i=2;i<=n;i++)g[i]=max(g[i-1],a[i]);

    for(int d=1;d<n;d++)
    {
        for(int k=1;k+d<=n;k++)
        {
            if(d==1)dp[d][k]=k+1;
            else
            {
                dp[d][k]=dp[d-1][k+1]+k*dp[d-1][k];
                dp[d][k]%=mod;
            }
        }
    }

    /*for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/

    long long ans=0;
    for(int i=2;i<=n;i++)
    {
        ll br;
        if(i==n)
        {
            br=1;
        }
        else if(g[i]==g[i-1])
        {
            br=dp[n-i][g[i]];
        }
        else
        {
            br=dp[n-i][g[i]-1];
        }


        ans+=(g[i]-1)*br;
        ans%=mod;
    }

    cout<<(ans+1)%mod<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 3324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 7288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 7288 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -