Submission #281159

# Submission time Handle Problem Language Result Execution time Memory
281159 2020-08-23T03:40:21 Z AQT Calvinball championship (CEOI15_teams) C++14
70 / 100
1000 ms 7552 KB
#include <bits/stdc++.h>

using namespace std;

int N;
int arr[1005];
long long dp[1005][1005];
const long long MOD = 1000007;

long long solve(int n, int m, bool border){
	if(n == N+1){
		return 1;
	}
	if(!border && dp[n][m]){
		return dp[n][m];
	}
	int lim = m+1;
	if(border){
		lim = arr[n];
	}
	long long ans = 0;
	for(int i = 1; i<=lim; i++){
		ans += solve(n+1, max(i, m), border && (i == lim));
	}
	ans %= MOD;
	if(!border){
		dp[n][m] = ans;
	}
	return ans;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N;
	for(int i = 1; i<=N; i++){
		cin >> arr[i];
	}
	cout << solve(1, 0, 1);
	
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 288 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 768 KB Output is correct
2 Correct 3 ms 768 KB Output is correct
3 Correct 3 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 133 ms 3412 KB Output is correct
2 Correct 117 ms 3320 KB Output is correct
3 Correct 149 ms 3320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 933 ms 7420 KB Output is correct
2 Correct 922 ms 7320 KB Output is correct
3 Correct 923 ms 7552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 7448 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -