# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
43992 | 2018-03-29T08:56:32 Z | sorry_Benq | Calvinball championship (CEOI15_teams) | C++17 | 132 ms | 1104 KB |
#include <bits/stdc++.h> #define int long long using namespace std; typedef long long ll; const int MOD = 1e6 + 7; ll a[10005]; ll DP[10005]; ll mxs[10005]; /*int solve(int N, int K){ //you have N numbers left, and they can start anywhere from 1 - K. if (DP[N][K] != 0) return DP[N][K]; if (N == 0) return 1; else{ return DP[N][K] = (((long long) K)*solve(N - 1, K) + solve(N - 1, K + 1))%MOD; } }*/ int cnt = 10005; void evolve(){ for (int i = 0; i < cnt - 1; i++){ DP[i] = ((long long) i)*DP[i] + DP[i + 1]; DP[i] %= MOD; } cnt--; } main(){ int N; cin >> N; for (int i = 0; i < N; i++){ cin >> a[i]; } for (int i = 0; i < cnt; i++){ DP[i] = 1; } ll res = 1; int mx = 1; for (int i = 0; i < N; i++){ mxs[i] = mx; mx = max(mx, a[i]); } for (int i = N - 1; i >= 0; i--){ //matches prefix of length i res += ((ll) a[i] - 1)*DP[mxs[i]]; evolve(); res %= MOD; } cout << res << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 516 KB | Output is correct |
3 | Correct | 2 ms | 516 KB | Output is correct |
4 | Correct | 2 ms | 516 KB | Output is correct |
5 | Correct | 2 ms | 516 KB | Output is correct |
6 | Correct | 2 ms | 592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 592 KB | Output is correct |
2 | Correct | 2 ms | 592 KB | Output is correct |
3 | Correct | 2 ms | 592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 592 KB | Output is correct |
2 | Correct | 2 ms | 592 KB | Output is correct |
3 | Correct | 2 ms | 592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 592 KB | Output is correct |
2 | Correct | 4 ms | 592 KB | Output is correct |
3 | Correct | 4 ms | 592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 592 KB | Output is correct |
2 | Correct | 14 ms | 660 KB | Output is correct |
3 | Correct | 13 ms | 660 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 660 KB | Output is correct |
2 | Correct | 24 ms | 716 KB | Output is correct |
3 | Correct | 24 ms | 716 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 132 ms | 844 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 85 ms | 844 KB | Output is correct |
2 | Correct | 90 ms | 844 KB | Output is correct |
3 | Correct | 97 ms | 948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 119 ms | 948 KB | Output is correct |
2 | Correct | 130 ms | 1104 KB | Output is correct |
3 | Correct | 116 ms | 1104 KB | Output is correct |