# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
34351 | mohammad_kilani | Calvinball championship (CEOI15_teams) | C++14 | 1000 ms | 6004 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 mod 1000007
#define oo 2000000000
const int N = 1010;
int arr[N] ;
int dp[N][N];
int n;
int solve(int i,int mx){
if(i == n){
return 1;
}
if(dp[i][mx] != -1) return dp[i][mx];
dp[i][mx] = 0;
for(int j=1;j<=mx+1;j++){
dp[i][mx] += solve(i+1,max(mx,j));
dp[i][mx] %= mod;
}
return dp[i][mx];
}
int main() {
//freopen("in.txt","r",stdin);
scanf("%d",&n);
memset(dp,-1,sizeof(dp));
for(int i=0;i<n;i++) scanf("%d",&arr[i]);
int ans = 1 , mx = 0 ;
for(int i=0;i<n;i++){
for(int j=1;j<arr[i];j++){
mx = max(mx,j);
ans+= solve(i+1,mx);
ans %= mod;
}
mx = max(mx,arr[i]);
}
cout << ans << endl;
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... |