# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
460904 | 2021-08-09T10:51:03 Z | kingfran1907 | Calvinball championship (CEOI15_teams) | C++14 | 486 ms | 476 KB |
#include <bits/stdc++.h> #define X first #define Y second using namespace std; typedef long long llint; const int maxn = 1e4+2; const int base = 31337; const int mod = 1e6+7; const int inf = 0x3f3f3f3f; const int logo = 18; const int off = 1 << logo; const int treesiz = off << 1; int n; int niz[maxn]; int dp[2][maxn]; int pref[maxn]; int mul(int a, int b) { llint out = (llint) a * b; return out % mod; } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", niz+i); } pref[0] = niz[0]; for (int i = 1; i < n; i++) pref[i] = max(pref[i - 1], niz[i]); int sol = 0; for (int i = 1; i <= n; i++) dp[0][i] = 1; int cnt = 1; for (int i = n - 1; i > 0; i--) { sol += mul(niz[i] - 1, dp[(n - i - 1) % 2][pref[i - 1]]); sol %= mod; for (int j = 1; j <= n; j++) dp[cnt][j] = (dp[1 - cnt][j + 1] + mul(j, dp[1 - cnt][j])) % mod; cnt = 1 - cnt; } printf("%d\n", sol + 1); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 204 KB | Output is correct |
2 | Correct | 2 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 292 KB | Output is correct |
2 | Correct | 6 ms | 320 KB | Output is correct |
3 | Correct | 5 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 383 ms | 476 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 99 ms | 380 KB | Output is correct |
2 | Correct | 99 ms | 384 KB | Output is correct |
3 | Correct | 96 ms | 388 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 386 ms | 460 KB | Output is correct |
2 | Correct | 486 ms | 460 KB | Output is correct |
3 | Correct | 379 ms | 468 KB | Output is correct |