# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
63165 | khsoo01 | Calvinball championship (CEOI15_teams) | C++11 | 471 ms | 1348 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;
typedef long long ll;
const ll N = 10005, mod = 1e6+7;
ll n, a[N], mx[N], dt[2][N];
int main()
{
scanf("%lld",&n);
for(ll i=1;i<=n;i++) {
scanf("%lld",&a[i]);
mx[i] = max(mx[i-1], a[i]);
dt[n%2][i] = 1;
}
ll ans = a[n];
for(ll i=n-1;i>=1;i--) {
for(ll j=1;j<=i;j++) {
dt[i%2][j] = (dt[1-i%2][j] * j + dt[1-i%2][j+1]) % mod;
}
for(ll j=1;j<a[i];j++) {
ans = (ans + dt[i%2][max(mx[i-1], j)]) % mod;
}
}
printf("%lld\n",ans);
}
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... |