# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
37363 | 2017-12-24T16:46:35 Z | cheater2k | Calvinball championship (CEOI15_teams) | C++14 | 736 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]) % md; 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
# | 결과 | 실행 시간 | 메모리 | 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 |
# | 결과 | 실행 시간 | 메모리 | 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 |
# | 결과 | 실행 시간 | 메모리 | 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2404 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2404 KB | Output is correct |
2 | Correct | 3 ms | 2404 KB | Output is correct |
3 | Correct | 0 ms | 2404 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2404 KB | Output is correct |
2 | Correct | 6 ms | 2404 KB | Output is correct |
3 | Correct | 6 ms | 2404 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 729 ms | 2668 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 179 ms | 2536 KB | Output is correct |
2 | Correct | 183 ms | 2536 KB | Output is correct |
3 | Correct | 183 ms | 2536 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 736 ms | 2536 KB | Output is correct |
2 | Correct | 726 ms | 2536 KB | Output is correct |
3 | Correct | 736 ms | 2668 KB | Output is correct |