답안 #82349

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
82349 2018-10-30T08:17:33 Z aminra Calvinball championship (CEOI15_teams) C++14
100 / 100
742 ms 1092 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
const int MOD = 1000007;
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;	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 456 KB Output is correct
5 Correct 2 ms 584 KB Output is correct
6 Correct 3 ms 584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 588 KB Output is correct
2 Correct 2 ms 588 KB Output is correct
3 Correct 2 ms 608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 608 KB Output is correct
2 Correct 2 ms 608 KB Output is correct
3 Correct 2 ms 612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 628 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 760 KB Output is correct
2 Correct 3 ms 780 KB Output is correct
3 Correct 4 ms 780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 780 KB Output is correct
2 Correct 6 ms 780 KB Output is correct
3 Correct 13 ms 780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 699 ms 1048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 1048 KB Output is correct
2 Correct 107 ms 1048 KB Output is correct
3 Correct 185 ms 1048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 435 ms 1080 KB Output is correct
2 Correct 436 ms 1080 KB Output is correct
3 Correct 742 ms 1092 KB Output is correct