제출 #900218

#제출 시각아이디문제언어결과실행 시간메모리
900218raphaelpCalvinball championship (CEOI15_teams)C++14
100 / 100
74 ms768 KiB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long N;
    cin >> N;
    vector<long long> Tab(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> Tab[i];
    }
    long long maxx = 0;
    vector<long long> id(N);
    for (long long i = 0; i < N; i++)
    {
        id[i] = max((long long)0, maxx - 1);
        maxx = max(maxx, Tab[i]);
    }
    vector<long long> dp(N, 1);
    vector<long long> temp(N, 1);
    for (long long i = N - 2; i >= 0; i--)
    {
        for (long long j = 0; j <= i; j++)
        {
            temp[j] = (temp[j + 1] + (temp[j] * (j + 1))) % 1000007;
        }
        dp[i] = temp[id[i]];
    }
    long long tot = 0;
    for (long long i = 0; i < N; i++)
    {
        tot += (Tab[i] - 1) * dp[i];
        tot = tot % 1000007;
    }
    cout << (tot + 1) % 1000007;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...