답안 #146739

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
146739 2019-08-25T19:16:54 Z vex Calvinball championship (CEOI15_teams) C++14
70 / 100
10 ms 7336 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+=(a[i]-1)*br;
        ans%=mod;
    }

    cout<<(ans+1)%mod<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 760 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3320 KB Output is correct
2 Correct 5 ms 3320 KB Output is correct
3 Correct 5 ms 3320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7336 KB Output is correct
2 Correct 9 ms 7288 KB Output is correct
3 Correct 9 ms 7288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 7288 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -