Submission #747691

# Submission time Handle Problem Language Result Execution time Memory
747691 2023-05-24T13:26:00 Z Trisanu_Das Calvinball championship (CEOI15_teams) C++17
100 / 100
333 ms 400 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5, MOD = 1e6 + 7;
int dp[N], a[N];
 
int main() {
    int n, mx = 0; cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        for (int j = n; j >= 2; j--) dp[j] = (1ll * dp[j] * j % MOD + dp[j - 1]) % MOD;
        dp[mx] = (dp[mx] + a[i] - 1) % MOD, mx = max(mx, a[i]);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) ans = (ans + dp[i]) % MOD;
    cout << ans + 1 << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 5 ms 316 KB Output is correct
3 Correct 4 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 314 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 88 ms 340 KB Output is correct
2 Correct 81 ms 340 KB Output is correct
3 Correct 85 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 333 ms 352 KB Output is correct
2 Correct 314 ms 392 KB Output is correct
3 Correct 311 ms 400 KB Output is correct