Submission #527286

# Submission time Handle Problem Language Result Execution time Memory
527286 2022-02-17T05:23:04 Z beepbeepsheep Calvinball championship (CEOI15_teams) C++17
0 / 100
38 ms 65540 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ii pair<ll,ll>
#define endl '\n'
const ll inf=1e15;
const ll mod=1e6+7;
const ll maxn=10005;

ll dp[maxn][maxn];
ll expo(ll n, ll x){
    if (x==0) return 1;
    if (x==1) return n;
    ll temp=expo(n,x/2);
    if (x&1){
        return (temp*(temp*n)%mod)%mod;
    }
    return (temp*temp)%mod;
}
ll solve(ll digit, ll rem){
    if (rem==0) return 1;
    if (dp[digit][rem]!=-1) return dp[digit][rem];
    ll ans=0;
    for (int i=1;i<=rem;i++){
        ans+=solve(digit+1,rem-i)*expo(digit,i-1);
        ans%=mod;
    }
    ans+=expo(digit,rem);
    ans%=mod;
    return dp[digit][rem]=ans%mod;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,ele,ans=0;
    cin>>n;
    ll ele2=0,temp;
    memset(dp,-1,sizeof(dp));
    for (int i=1;i<=n;i++){
        cin>>ele;
        for (int j=1;j<ele;j++){
            temp=max<ll>(j,ele2);
            ans+=solve(temp,n-i);
            ans%=mod;
        }
        ele2=max(ele,ele2);
    }
    cout<<(ans+1)%mod;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 36 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 34 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 38 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 37 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 28 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -