Submission #527351

# Submission time Handle Problem Language Result Execution time Memory
527351 2022-02-17T09:24:34 Z beepbeepsheep Calvinball championship (CEOI15_teams) C++17
100 / 100
540 ms 656 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#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],nxt[maxn],arr[maxn],pref[maxn];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,ans=0;
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>arr[i];
        dp[i]=1;
        pref[i]=max(arr[i],pref[i-1]);
    }
    for (int i=n;i>=1;i--){
        for (int j=1;j<maxn-1;j++){
            nxt[j]=(dp[j]*(j))%mod+dp[j+1];
            nxt[j]%=mod;
        }
        for (int j=1;j<arr[i];j++){
            ans+=dp[max<ll>(j,pref[i-1])];
            ans%=mod;
        }
        swap(dp,nxt);
    }
    cout<<(ans+1)%mod;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 460 KB Output is correct
2 Correct 5 ms 460 KB Output is correct
3 Correct 4 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 480 KB Output is correct
2 Correct 18 ms 460 KB Output is correct
3 Correct 16 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 460 KB Output is correct
2 Correct 33 ms 460 KB Output is correct
3 Correct 34 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 540 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 162 ms 544 KB Output is correct
2 Correct 162 ms 452 KB Output is correct
3 Correct 216 ms 564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 381 ms 608 KB Output is correct
2 Correct 322 ms 636 KB Output is correct
3 Correct 539 ms 656 KB Output is correct