Submission #1081787

# Submission time Handle Problem Language Result Execution time Memory
1081787 2024-08-30T10:47:32 Z Elias Calvinball championship (CEOI15_teams) C++17
20 / 100
35 ms 65536 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

int mod = 1e9 + 7;

signed main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int n;
	cin >> n;

	vector<int> a(n);

	for (int &x : a)
		cin >> x;

	vector<int> pref = a;

	for (int i = 1; i < n; i++)
	{
		pref[i] = max(pref[i - 1], pref[i]);
	}

	vector<vector<int>> dp(n, vector<int>(n + 1, 1));

	int count = 1;

	for (int i = n - 1; i >= 1; i--)
	{
		if (i != n - 1)
		{
			for (int max_here = 1; max_here <= i; max_here++)
			{
				dp[i][max_here] = ((dp[i + 1][max_here] * max_here) % mod + dp[i + 1][max_here + 1]) % mod;
			}
		}
		count += ((dp[i][pref[i - 1]]) * (a[i] - 1)) % mod;
		count %= mod;
	}

	cout << count;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 8284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 35 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 35 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -