# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
54389 | 2018-07-03T09:47:34 Z | Costin Andrei Oncescu(#1303) | Calvinball championship (CEOI15_teams) | C++11 | 187 ms | 1000 KB |
#include<bits/stdc++.h> using namespace std; int ans, a[10009], b[10009], N, dp[2][10009]; const int mod = 1e6 + 7; int main () { //freopen ("input", "r", stdin); //freopen ("output", "w", stdout); scanf ("%d", &N), ans = 1; for (int i=1; i<=N; i++) scanf ("%d", &a[i]), b[i] = max (b[i - 1], a[i]); for (int i=1; i<=N; i++) dp[N & 1][i] = 1; for (int i=N; i>=1; i--) { if (i != N) { int curr = (i & 1), nxt = curr ^ 1; for (int j=1; j<=i; j++) dp[curr][j] = (1LL * dp[nxt][j] * j + dp[nxt][j + 1]) % mod; } for (int j=1; j<a[i]; j++) { ans += dp[i & 1][max (b[i - 1], j)]; if (ans >= mod) ans -= mod; } } printf ("%d\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 432 KB | Output is correct |
4 | Correct | 2 ms | 468 KB | Output is correct |
5 | Correct | 2 ms | 544 KB | Output is correct |
6 | Correct | 3 ms | 544 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 544 KB | Output is correct |
2 | Correct | 2 ms | 544 KB | Output is correct |
3 | Correct | 2 ms | 544 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 544 KB | Output is correct |
2 | Correct | 2 ms | 544 KB | Output is correct |
3 | Correct | 2 ms | 580 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 600 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 600 KB | Output is correct |
2 | Correct | 2 ms | 600 KB | Output is correct |
3 | Correct | 2 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 608 KB | Output is correct |
2 | Correct | 2 ms | 608 KB | Output is correct |
3 | Correct | 3 ms | 648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 664 KB | Output is correct |
2 | Correct | 4 ms | 664 KB | Output is correct |
3 | Correct | 4 ms | 664 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 187 ms | 796 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 796 KB | Output is correct |
2 | Correct | 38 ms | 796 KB | Output is correct |
3 | Correct | 48 ms | 796 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 122 ms | 848 KB | Output is correct |
2 | Correct | 122 ms | 884 KB | Output is correct |
3 | Correct | 187 ms | 1000 KB | Output is correct |