# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40414 | Pajaraja | Calvinball championship (CEOI15_teams) | C++14 | 367 ms | 1436 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;
const int MOD=1000007;
long long dp[10007],dpl[10007];
long long a[10007],parc[10007];
int main()
{
long long cur=0;
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
parc[0]=0;
for(int i=1;i<=n;i++) parc[i]=fmax(parc[i-1],a[i]);
for(int i=1;i<=n;i++) dp[i]=1;
for(int j=n;j>=1;j--)
{
cur=(cur+dp[parc[j-1]]*(min(parc[j-1],a[j]-1)))%MOD;
for(int i=parc[j-1]+1;i<a[j];i++) cur=(cur+dp[i])%MOD;
for(int i=1;i<=n;i++) dpl[i]=dp[i];
for(int i=1;i<=n;i++) dp[i]=(i*dpl[i]+dpl[i+1])%MOD;
}
printf("%d",cur+1);
}
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... |