Submission #530723

# Submission time Handle Problem Language Result Execution time Memory
530723 2022-02-26T15:02:46 Z Yazan_Alattar Calvinball championship (CEOI15_teams) C++14
60 / 100
1000 ms 65540 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 10007;
const ll inf = 2e9;
const ll mod = 1e6 + 7;
const double pi = acos(-1);
const int dx[] = {0, -1, 0, 1}, dy[] = {1, 0, -1, 0};
const int block = 320;

ll n, a[M], dp[M][M], pref[M], ans = 1;

ll solve(int i, int team){
	if(i < 1 || team > n) return 0;
	if(i == n) return 1;
	
	ll &ret = dp[i][team];
	if(ret != -1) return ret;
	ret = 0;
	
	for(int j = 1; j <= team + 1; ++j) ret = (ret + solve(i + 1, max(team, j))) % mod;
	
	return ret;
	
}

int main(){
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> a[i], pref[i] = max(pref[i - 1], a[i]);
	
	for(int i = 0; i <= n; ++i) for(int j = 0; j <= n; ++j) dp[i][j] = -1;
	
	for(int i = 1; i <= n; ++i) for(ll j = 1; j < a[i]; ++j) ans = (ans + solve(i, max(pref[i - 1], j))) % mod;
	
	cout << ans << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 716 KB Output is correct
2 Correct 2 ms 716 KB Output is correct
3 Correct 2 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 145 ms 4364 KB Output is correct
2 Correct 144 ms 4364 KB Output is correct
3 Correct 142 ms 4300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 12348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 34 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 34 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -