# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
221872 | 2020-04-11T11:17:26 Z | PeppaPig | Calvinball championship (CEOI15_teams) | C++14 | 369 ms | 760 KB |
#include <bits/stdc++.h> #define long long long using namespace std; const int N = 1e4+5; const int M = 1e6+7; int n, A[N], mx[N]; long dp[2][N]; int main() { scanf("%d", &n); for(int i = 1; i <= n; i++) { scanf("%d", A + i); mx[i] = max(mx[i - 1], A[i]), dp[0][i] = 1; } long ans = 1ll * (A[n] - 1) * dp[0][mx[n - 1]]; for(int i = 1; i <= n; i++) { int now = i & 1, pre = now ^ 1; for(int j = 0; j <= n; j++) dp[now][j] = (1ll * j * dp[pre][j] % M + dp[pre][j + 1]) % M; if(i < n) ans = (ans + (A[n - i] - 1) * dp[now][mx[n - i - 1]]) % M; } printf("%lld\n", ans + 1); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 384 KB | Output is correct |
2 | Correct | 8 ms | 384 KB | Output is correct |
3 | Correct | 8 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 362 ms | 760 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 95 ms | 504 KB | Output is correct |
2 | Correct | 98 ms | 512 KB | Output is correct |
3 | Correct | 97 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 367 ms | 512 KB | Output is correct |
2 | Correct | 368 ms | 512 KB | Output is correct |
3 | Correct | 369 ms | 760 KB | Output is correct |