Submission #958864

# Submission time Handle Problem Language Result Execution time Memory
958864 2024-04-07T01:51:48 Z Ghetto Calvinball championship (CEOI15_teams) C++17
20 / 100
39 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int MAX_N = 1e4 + 5;
const lint MOD = 1e9 + 7;

int n;
int arr[MAX_N];

lint mod(lint x) {
    return x % MOD;
}

lint dp[MAX_N][MAX_N];
void precomp() {
    for (int s = n; s >= 1; s--) {
        for (int t = 1; t <= s; t++) {
            if (s == n) dp[s][t] = 1;
            else dp[s][t] = mod(dp[s + 1][t + 1] + mod(t * dp[s + 1][t]));
        }
    }
}

int main() {
    // freopen("calvin.in", "r", stdin);

    cin >> n;
    for (int i = 1; i <= n; i++) cin >> arr[i];

    precomp();

    set<int> unis;
    lint ans = 0;
    for (int i = 1; i <= n; i++) {
        lint n_unis = unis.size();
        ans = mod(ans + mod(dp[i][n_unis] * (arr[i] - 1))); // Should be fine if n_unis = 0

        unis.insert(arr[i]);
    }
    ans++;
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 8540 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 8536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 39260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 65116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 39 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 25 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 39 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -