Submission #1072999

# Submission time Handle Problem Language Result Execution time Memory
1072999 2024-08-24T08:19:57 Z vjudge1 Calvinball championship (CEOI15_teams) C++17
100 / 100
83 ms 560 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
const int maxN=1e4+5,MOD=1000007;
const ll inf=2e18;
int n,a[maxN+1],dp[maxN+1];
int main()
{
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    memset(dp,0,sizeof(dp));
    int ans=0,mx=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=i;j>=2;j--)
        {
            dp[j]=(1LL*dp[j]*j+dp[j-1])%MOD;
        }
        dp[mx]=(dp[mx]+a[i]-1)%MOD;
        mx=max(mx,a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        ans=(ans+dp[i])%MOD;
    }
    cout<<(ans+1)%MOD;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 348 KB Output is correct
2 Correct 19 ms 348 KB Output is correct
3 Correct 19 ms 552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 348 KB Output is correct
2 Correct 77 ms 348 KB Output is correct
3 Correct 83 ms 560 KB Output is correct