답안 #1081794

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1081794 2024-08-30T10:58:09 Z Elias Calvinball championship (CEOI15_teams) C++17
100 / 100
229 ms 872 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

int mod = 1e6 + 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(2, 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 + 1; max_here++)
			{
				dp[i % 2][max_here] = ((dp[(i + 1) % 2][max_here] * max_here) % mod + dp[(i + 1) % 2][max_here + 1]) % mod;
			}
		}
		count += ((dp[i % 2][pref[i - 1]]) * (a[i] - 1)) % mod;
		count %= mod;
	}

	cout << count;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 3 ms 496 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 223 ms 872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 660 KB Output is correct
2 Correct 58 ms 604 KB Output is correct
3 Correct 58 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 229 ms 860 KB Output is correct
2 Correct 229 ms 860 KB Output is correct
3 Correct 228 ms 868 KB Output is correct