Submission #69072

# Submission time Handle Problem Language Result Execution time Memory
69072 2018-08-19T21:23:13 Z Bodo171 Calvinball championship (CEOI15_teams) C++14
10 / 100
781 ms 1268 KB
#include <iostream>
#include <fstream>
using namespace std;
const int nmax=10005;
const long long mod=1000*1000+7;
long long c[2][nmax],bell[nmax],mx[nmax],pw[nmax];
long long ans;
int v[nmax];
int n,i,j,use;
int main()
{
    //freopen("data.in","r",stdin);
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>v[i];
        mx[i]=max(mx[i-1],1LL*v[i]);
    }
    bell[0]=1;
    ans=v[n]-1;
    for(i=1;i<n;i++)
    {
        use=1-use;
        c[use][0]=1;
        for(j=1;j<=i;j++)
        {
            c[use][j]=(c[1-use][j]+c[1-use][j-1])%mod;
        }
        if(i==1)
            c[use][1]=1;
        pw[0]=v[n-i]-1;
        for(j=1;j<=i;j++)
            pw[j]=(1LL*pw[j-1]*mx[n-i-1])%mod;
        for(j=1;j<=i;j++)
        {
            bell[i]=(1LL*bell[i]+(bell[i-j]*c[use][j]))%mod;
            ans=(ans+1LL*bell[i-j]*c[use][j]*pw[j])%mod;
        }
        ans=(ans+bell[i]*pw[0])%mod;
    }
    cout<<(ans+1)%mod;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 508 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 668 KB Output is correct
5 Correct 2 ms 668 KB Output is correct
6 Correct 2 ms 668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 668 KB Output is correct
2 Incorrect 2 ms 668 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 668 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 738 ms 1268 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 190 ms 1268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 781 ms 1268 KB Output isn't correct
2 Halted 0 ms 0 KB -