# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
90749 | Vinhspm | Calvinball championship (CEOI15_teams) | C++14 | 96 ms | 66560 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 = 1e5 + 10;
const int mod = 1e6 + 7;
int n, num;
int a[N], cnt[N];
vector<int> f[N];
void add(int &x, int y) { x = (x + y) % mod; }
signed main()
{
scanf("%d", &n);
FOR(i, 1, n) scanf("%d", &a[i]);
FOR(i, 0, n + 1) f[i].assign(i + 5, 0);
FOR(i, 0, n) f[n + 1][i] = 1;
for(int i = n; i >= 1; --i) FOR(j, 0, i) {
add(f[i][j], f[i + 1][j] * j);
add(f[i][j], f[i + 1][j + 1]);
}
int sum = 1;
FOR(i, 1, n) {
for(int j = 1; j < a[i]; ++j) {
cnt[j] ++; if(cnt[j] == 1) num ++;
add(sum, f[i + 1][num]);
cnt[j] --; if(cnt[j] == 0) num --;
}
cnt[ a[i] ] ++; if(cnt[ a[i] ] == 1) num ++;
}
printf("%d", sum);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |