Submission #900218

# Submission time Handle Problem Language Result Execution time Memory
900218 2024-01-07T22:24:32 Z raphaelp Calvinball championship (CEOI15_teams) C++14
100 / 100
74 ms 768 KB
#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 time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 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 1 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
# 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 1 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 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 604 KB Output is correct
2 Correct 20 ms 596 KB Output is correct
3 Correct 19 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 756 KB Output is correct
2 Correct 73 ms 544 KB Output is correct
3 Correct 74 ms 768 KB Output is correct