답안 #1072997

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1072997 2024-08-24T08:18:16 Z DucNguyen2007 Calvinball championship (CEOI15_teams) C++14
100 / 100
95 ms 604 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],s[maxN+1];
int main()
{
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    s[0]=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        s[i]=max(s[i-1],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;
}
# 결과 실행 시간 메모리 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
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 348 KB Output is correct
2 Correct 22 ms 344 KB Output is correct
3 Correct 26 ms 516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 580 KB Output is correct
2 Correct 85 ms 348 KB Output is correct
3 Correct 95 ms 600 KB Output is correct