Submission #48443

# Submission time Handle Problem Language Result Execution time Memory
48443 2018-05-13T15:05:47 Z IvanC Calvinball championship (CEOI15_teams) C++17
70 / 100
704 ms 8784 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int MAXN = 1010;
const ll MOD =  1000007LL;

ll dp[MAXN][MAXN],tot;
int N,vetor[MAXN];

ll solve(int pos,int maior){
	if(dp[pos][maior] != -1) return dp[pos][maior];
	if(pos == N + 1){
		return dp[pos][maior] = 1;
	}
	ll ans = 0;
	for(int i = 1;i<maior;i++){
		ans += solve(pos+1,maior);
	}
	ans += solve(pos+1,maior+1);
	return dp[pos][maior] = ans % MOD;
}

int main(){
	cin >> N;
	for(int i = 1;i<=N;i++) cin >> vetor[i];
	memset(dp,-1,sizeof(dp));
	int maior = 0;
	for(int i = 1;i<=N;i++){
		for(int j = 1;j<vetor[i];j++){
			tot += solve(i+1,max(j,maior) + 1);
		}
		maior = max(maior,vetor[i]);
		tot %= MOD;
	}
	tot++;
	tot %= MOD;
	cout << tot << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8312 KB Output is correct
2 Correct 8 ms 8312 KB Output is correct
3 Correct 8 ms 8368 KB Output is correct
4 Correct 8 ms 8572 KB Output is correct
5 Correct 8 ms 8572 KB Output is correct
6 Correct 7 ms 8572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8572 KB Output is correct
2 Correct 8 ms 8572 KB Output is correct
3 Correct 8 ms 8572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8576 KB Output is correct
2 Correct 8 ms 8576 KB Output is correct
3 Correct 8 ms 8612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8616 KB Output is correct
2 Correct 10 ms 8616 KB Output is correct
3 Correct 9 ms 8616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 8752 KB Output is correct
2 Correct 97 ms 8752 KB Output is correct
3 Correct 97 ms 8752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 677 ms 8752 KB Output is correct
2 Correct 672 ms 8760 KB Output is correct
3 Correct 675 ms 8784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 704 ms 8784 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 8784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 8784 KB Output isn't correct
2 Halted 0 ms 0 KB -