# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
90757 | 2018-12-24T09:25:45 Z | Vinhspm | Calvinball championship (CEOI15_teams) | C++14 | 511 ms | 1044 KB |
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define FOR(a, b, c) for(int a = b; a <= c; ++a) #define pb push_back const int N = 1e4 + 5; const int mod = 1e6 + 7; int n, num; int a[N], cnt[N]; int f[2][N]; void add(int &x, int y) { x = (x + y) % mod; } signed main() { scanf("%d", &n); FOR(i, 1, n) { scanf("%d", &a[i]), cnt[ a[i] ] ++; if(cnt[ a[i] ] == 1) num ++; } int sum = 1, las = 0, nex = 1; FOR(i, 0, n) f[las][i] = 1; for(int i = n; i >= 1; --i) { FOR(j, 0, i) { add(f[nex][j], 1ll * f[las][j] * 1ll * j % mod); add(f[nex][j], f[las][j + 1]); } cnt[ a[i] ] --; if(cnt[ a[i] ] == 0) num --; FOR(t, 1, a[i] - 1) { cnt[t] ++; if(cnt[t] == 1) num ++; add(sum, f[las][num]); cnt[t] --; if(cnt[t] == 0) num --; } swap(nex, las); FOR(j, 0, i) f[nex][j] = 0; } printf("%d", sum); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 1 ms | 468 KB | Output is correct |
3 | Correct | 1 ms | 484 KB | Output is correct |
4 | Correct | 2 ms | 484 KB | Output is correct |
5 | Correct | 2 ms | 484 KB | Output is correct |
6 | Correct | 2 ms | 484 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 512 KB | Output is correct |
2 | Correct | 2 ms | 544 KB | Output is correct |
3 | Correct | 2 ms | 560 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 560 KB | Output is correct |
2 | Correct | 2 ms | 560 KB | Output is correct |
3 | Correct | 2 ms | 608 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 608 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 608 KB | Output is correct |
2 | Correct | 2 ms | 608 KB | Output is correct |
3 | Correct | 2 ms | 608 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 608 KB | Output is correct |
2 | Correct | 3 ms | 740 KB | Output is correct |
3 | Correct | 3 ms | 740 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 740 KB | Output is correct |
2 | Correct | 5 ms | 740 KB | Output is correct |
3 | Correct | 7 ms | 740 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 495 ms | 756 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 76 ms | 756 KB | Output is correct |
2 | Correct | 75 ms | 756 KB | Output is correct |
3 | Correct | 130 ms | 756 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 298 ms | 768 KB | Output is correct |
2 | Correct | 304 ms | 1044 KB | Output is correct |
3 | Correct | 511 ms | 1044 KB | Output is correct |