# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
476794 | 2021-09-28T14:05:15 Z | ntabc05101 | Calvinball championship (CEOI15_teams) | C++17 | 629 ms | 588 KB |
#include<bits/stdc++.h> using namespace std; #define taskname "" const int mxN = 10000; const int mod = 1e6 + 7; long long dp[2][mxN + 1]; #define dp(x) dp[(x) & 1] int a[mxN + 1], mx[mxN + 1]; int main() { if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } else { if (fopen(taskname".in", "r")) { freopen(taskname".in", "r", stdin); freopen(taskname".out", "w", stdout); } } cin.tie(0)->sync_with_stdio(0); int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; mx[i] = max(mx[i - 1], a[i]); } for (int i = 1; i <= n; i++) { dp(0)[i] = 1; } long long res = 1; for (int i = n - 1; i; i--) { for (int j = 1; j <= n; j++) { (dp(n - i)[j] = 1ll * j * dp(n - i - 1)[j]) %= mod; (dp(n - i)[j] += dp(n - i - 1)[j + 1]) %= mod; } for (int j = a[i] - 1; j; j--) { (res += dp(n - i)[max(mx[i - 1], j)]) %= mod; } } (res += a[n] - 1) %= mod; cout << res << "\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 2 ms | 332 KB | Output is correct |
3 | Correct | 2 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 332 KB | Output is correct |
2 | Correct | 5 ms | 332 KB | Output is correct |
3 | Correct | 7 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 596 ms | 528 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 102 ms | 432 KB | Output is correct |
2 | Correct | 99 ms | 460 KB | Output is correct |
3 | Correct | 156 ms | 460 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 382 ms | 528 KB | Output is correct |
2 | Correct | 377 ms | 460 KB | Output is correct |
3 | Correct | 629 ms | 588 KB | Output is correct |