답안 #1107871

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1107871 2024-11-02T09:03:09 Z 12345678 Calvinball championship (CEOI15_teams) C++17
100 / 100
158 ms 656 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int nx=1e4+5, mod=1e6+7;

ll n, a[nx], h[nx], res, dp[2][nx];

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++) cin>>a[i], h[i]=max(h[i-1], a[i]);
    for (int i=1; i<=n; i++) dp[0][i]=1;
    a[0]=1;
    for (int i=1; i<=n; i++) 
    {
        int c=i%2, p=1-c;
        res=(res+(dp[p][h[n-i]])*(a[n-i+1]-1))%mod;
        for (int j=1; j<=n; j++) dp[c][j]=(dp[p][j]*j+dp[p][j+1])%mod; //cout<<"debug "<<i<<' '<<j<<' '<<dp[c][j]<<'\n';
    }
    cout<<(res+1)%mod;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 336 KB Output is correct
2 Correct 3 ms 336 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 145 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 592 KB Output is correct
2 Correct 38 ms 592 KB Output is correct
3 Correct 41 ms 656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 158 ms 592 KB Output is correct
2 Correct 148 ms 592 KB Output is correct
3 Correct 148 ms 592 KB Output is correct