Submission #1004643

# Submission time Handle Problem Language Result Execution time Memory
1004643 2024-06-21T11:10:54 Z Valaki2 Calvinball championship (CEOI15_teams) C++14
10 / 100
265 ms 640 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second

const int mod = 1e6 + 7;

void solve() {
    int n;
    cin >> n;
    vector<int> v(1 + n, 0);
    for(int i = 1; i <= n; i++) {
        cin >> v[i];
    }
    vector<int> dp(1 + n, 0);
    for(int i = 1; i <= n; i++) {
        dp[i] = 1;
    }
    int ans = 0;
    for(int i = n; i >= 1; i--) {
        for(int j = 1; j <= v[i] - 1; j++) {
            ans += dp[j];
            ans %= mod;
        }
        for(int j = 1; j <= i - 1; j++) {
            dp[j] = dp[j] * j + dp[j + 1];
            dp[j] %= mod;
        }
    }
    ans++;
    ans %= mod;
    cout << ans << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}
# 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
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 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 Incorrect 1 ms 456 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 265 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 572 KB Output isn't correct
2 Halted 0 ms 0 KB -