Submission #82346

# Submission time Handle Problem Language Result Execution time Memory
82346 2018-10-30T08:10:01 Z aminra Calvinball championship (CEOI15_teams) C++14
20 / 100
717 ms 1136 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
const int MOD = 1e9 + 7;
const int base = 37;
const int MAXN = (int)1e4 + 7;
const int infint = (int)1e9;
const ll inf = (ll)1e18;
ll n, a[MAXN], dp[MAXN], tmp[MAXN], mx[MAXN];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	mx[0] = a[0];
	for (int i = 1; i < n; i++)
		mx[i] = max(mx[i - 1], a[i]);
	for (int i = 0; i <= n; i++)
		dp[i] = 1;
	ll ans = a[n - 1] - 1;
	for (int i = n - 2; i >= 0; i--)
	{
		for (int j = 0; j <= n; j++)
			tmp[j] = (j * dp[j] % MOD + dp[j + 1]) % MOD;
		for (int j = 0; j <= n; j++)
			dp[j] = tmp[j];
		for (int k = 1; k < a[i]; k++)
		{
			ll t = k;
			if(i)
				t = max(t, mx[i - 1]);
			ans += dp[t], ans %= MOD;
		}
	}
	cout << (ans + 1) % MOD;	
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 456 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 628 KB Output is correct
3 Correct 2 ms 648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 656 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 660 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 717 ms 1060 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 1060 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 437 ms 1136 KB Output isn't correct
2 Halted 0 ms 0 KB -