# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96780 | Retro3014 | Calvinball championship (CEOI15_teams) | C++17 | 677 ms | 632 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 <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;
#define DIV 1000007
#define MAX_N 10000
typedef long long ll;
int N;
ll DP1[MAX_N+1], DP2[MAX_N+1];
int arr[MAX_N+1];
int main(){
scanf("%d", &N);
for(int i=1; i<=N; i++){
scanf("%d", &arr[i]);
}
int mx = 0;
for(int i=1; i<=N; i++){
for(int j=1; j<=N; j++){
DP2[j] =(DP1[j] * (ll)j + DP1[j -1]) % DIV;
}
for(int j=1; j<arr[i]; j++){
DP2[max(mx, j)] = (DP2[max(mx, j)]+1)%DIV;
}
mx = max(mx, arr[i]);
for(int j=0; j<=N; j++){
DP1[j] = DP2[j]; DP2[j] = 0;
}
}
ll ans = 0;
for(int i=1; i<=N; i++){
ans = (ans+DP1[i])%DIV;
}
printf("%lld", ans+1);
return 0;
}
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... |