# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
37362 | 2017-12-24T16:45:43 Z | cheater2k | Calvinball championship (CEOI15_teams) | C++14 | 189 ms | 2668 KB |
#include <bits/stdc++.h> using namespace std; const int N = 10005; const int md = 1000007; int n, a[N], b[N], dp[2][N], ans; vector< pair<int,int> > vec[N]; void add(int &x, int y) { x += y; while(x >= md) x -= md; if (x < 0) x += md; } int main() { scanf("%d", &n); int mx = 0; for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); int cur = min(a[i] - 1, mx); b[i] = mx; mx = max(mx, a[i]); a[i] = cur; vec[b[i]].push_back(make_pair(a[i], n - i)); } // + a[i] * dp[n - i][b[i]] dp[n & 1][0] = 1; for (int i = 1; i <= n; ++i) dp[n & 1][i] = 1LL * dp[n & 1][i - 1] * n % md; for (int ngroup = n - 1; ngroup >= 1; --ngroup) { int t = ngroup & 1; int cur = 1; dp[t][0] = 1; for (int i = 1; i <= n; ++i) { cur = (1LL * cur * ngroup) + dp[t ^ 1][i - 1]; dp[t][i] = cur; //printf("%d %d %d\n", ngroup, i, dp[t][i]); } for (auto it : vec[ngroup]) { add(ans, 1LL * it.first * dp[t][it.second] % md); } } printf("%d\n", (ans + 1) % md); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2404 KB | Output is correct |
2 | Correct | 0 ms | 2404 KB | Output is correct |
3 | Correct | 0 ms | 2404 KB | Output is correct |
4 | Correct | 0 ms | 2404 KB | Output is correct |
5 | Correct | 0 ms | 2404 KB | Output is correct |
6 | Correct | 0 ms | 2404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2404 KB | Output is correct |
2 | Correct | 0 ms | 2404 KB | Output is correct |
3 | Correct | 0 ms | 2404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2404 KB | Output is correct |
2 | Correct | 0 ms | 2404 KB | Output is correct |
3 | Correct | 0 ms | 2404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 2404 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 2404 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 2404 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 2404 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 189 ms | 2668 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 46 ms | 2536 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 189 ms | 2536 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |