# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
72883 | 2018-08-27T07:23:28 Z | arman_ferdous | Calvinball championship (CEOI15_teams) | C++17 | 544 ms | 1288 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1e4+10; const int mod = 1e6+7; int n, arr[N], pre[N]; long long dp[2][N]; int main() { scanf("%d", &n); pre[0] = -1; for(int i = 1; i <= n; i++) { scanf("%d", &arr[i]); pre[i] = max(pre[i-1], arr[i]); } for(int i = 0; i < N; i++) dp[0][i] = 1; int ro = 1, ans = 0; for(int i = n-1; i > 0; i--) { for(int val = 1; val <= n; val++) dp[ro][val] = ( val * dp[ro^1][val] + dp[ro^1][val+1] ) % mod; for(int val = 1; val < arr[i+1]; val++) ans = (ans + dp[ro^1][max(pre[i],val)]) % mod; ro ^= 1; } printf("%d\n", ans + 1); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 520 KB | Output is correct |
3 | Correct | 2 ms | 536 KB | Output is correct |
4 | Correct | 3 ms | 600 KB | Output is correct |
5 | Correct | 2 ms | 696 KB | Output is correct |
6 | Correct | 2 ms | 760 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 760 KB | Output is correct |
2 | Correct | 2 ms | 760 KB | Output is correct |
3 | Correct | 2 ms | 760 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 760 KB | Output is correct |
2 | Correct | 3 ms | 840 KB | Output is correct |
3 | Correct | 2 ms | 844 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 844 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 844 KB | Output is correct |
2 | Correct | 3 ms | 884 KB | Output is correct |
3 | Correct | 4 ms | 884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 884 KB | Output is correct |
2 | Correct | 4 ms | 884 KB | Output is correct |
3 | Correct | 4 ms | 884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 884 KB | Output is correct |
2 | Correct | 5 ms | 884 KB | Output is correct |
3 | Correct | 9 ms | 884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 534 ms | 1080 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 64 ms | 1080 KB | Output is correct |
2 | Correct | 60 ms | 1080 KB | Output is correct |
3 | Correct | 128 ms | 1112 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 214 ms | 1112 KB | Output is correct |
2 | Correct | 246 ms | 1236 KB | Output is correct |
3 | Correct | 544 ms | 1288 KB | Output is correct |