Submission #48444

# Submission time Handle Problem Language Result Execution time Memory
48444 2018-05-13T15:06:46 Z IvanC Calvinball championship (CEOI15_teams) C++17
0 / 100
2 ms 432 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int MAXN = 10010;
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 = (maior - 1)*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 Runtime error 2 ms 128 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 352 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 352 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 432 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -