# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
90754 | 2018-12-24T09:20:04 Z | Vinhspm | Calvinball championship (CEOI15_teams) | C++14 | 398 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], f[las][j] * j); 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 | 2 ms | 464 KB | Output is correct |
3 | Correct | 2 ms | 464 KB | Output is correct |
4 | Correct | 2 ms | 564 KB | Output is correct |
5 | Correct | 2 ms | 564 KB | Output is correct |
6 | Correct | 2 ms | 564 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 564 KB | Output is correct |
2 | Correct | 2 ms | 564 KB | Output is correct |
3 | Correct | 2 ms | 704 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 704 KB | Output is correct |
2 | Correct | 2 ms | 704 KB | Output is correct |
3 | Correct | 2 ms | 704 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 704 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 704 KB | Output is correct |
2 | Correct | 2 ms | 704 KB | Output is correct |
3 | Correct | 2 ms | 704 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 704 KB | Output is correct |
2 | Correct | 2 ms | 704 KB | Output is correct |
3 | Correct | 3 ms | 708 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 728 KB | Output is correct |
2 | Correct | 4 ms | 728 KB | Output is correct |
3 | Correct | 6 ms | 728 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 398 ms | 852 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 51 ms | 900 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 197 ms | 1044 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |