답안 #591524

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
591524 2022-07-07T14:36:02 Z andrei_boaca Calvinball championship (CEOI15_teams) C++14
100 / 100
346 ms 612 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod=1e6+7;
ll n,v[10005],dp[3][10005],ans;
int need[10005];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>v[i];
    int maxim=0;
    for(int i=1;i<=n;i++)
    {
        bool newmax=0;
        if(v[i]>maxim)
        {
            maxim=v[i];
            newmax=1;
        }
        need[n-i]=maxim-newmax;
    }
    need[0]=1;
    for(int i=1;i<=n;i++)
        dp[0][i]=i+1;
    need[1]=dp[0][need[1]];
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            ll val=(1LL*j*dp[0][j])%mod;
            val=(val+dp[0][j+1])%mod;
            dp[1][j]=val;
        }
        need[i]=dp[1][need[i]];
        for(int j=1;j<=n;j++)
            dp[0][j]=dp[1][j];
    }
    maxim=0;
    for(int i=1;i<=n;i++)
    {
        bool newmax=0;
        if(v[i]>maxim)
        {
            maxim=v[i];
            newmax=1;
        }
        ll val=(1LL*((v[i]-1)*need[n-i]))%mod;
        ans=(ans+val)%mod;
    }
    ans++;
    ans%=mod;
    cout<<ans;
    return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:43:14: warning: variable 'newmax' set but not used [-Wunused-but-set-variable]
   43 |         bool newmax=0;
      |              ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 260 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 5 ms 316 KB Output is correct
3 Correct 4 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 330 ms 560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 340 KB Output is correct
2 Correct 84 ms 572 KB Output is correct
3 Correct 82 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 346 ms 588 KB Output is correct
2 Correct 335 ms 596 KB Output is correct
3 Correct 345 ms 612 KB Output is correct