답안 #1111169

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1111169 2024-11-11T15:39:43 Z Ghulam_Junaid Calvinball championship (CEOI15_teams) C++17
70 / 100
16 ms 16720 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
const ll N = 1e3 + 10;
const ll mod = 1e6 + 7;
ll n, ans, a[N], dp[N][N];
 
ll pwr(ll a, ll b){
	if (b == 0)
		return 1;
 
	ll val = pwr(a, b/2);
	val *= val;
	val %= mod;
 
	if (b&1)
		val *= a;
	val %= mod;
 
	return val;
}
 
int main()
{
	cin >> n;
	for (ll i=1; i<=n; i++){
		cin >> a[i];
	}
	for (ll i=n; i>0; i--){
		for (ll j=1; j<=n; j++){
			if (i==n){
				dp[i][j] = dp[i][j-1] + 1;
				continue;
			}
			dp[i][j] = (j-1) * dp[i+1][j] + dp[i+1][j+1];
			dp[i][j] %= mod;
		}
	}
 
	ll mx = 0;
	for (ll i=1; i<n; i++){
		ans += (a[i] - 1) * dp[i+1][mx+1];
		ans %= mod;
		mx = max(mx, a[i]);
	}
	ans += dp[n][a[n]];
	ans %= mod;
	cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 504 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 848 KB Output is correct
2 Correct 1 ms 848 KB Output is correct
3 Correct 1 ms 848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4176 KB Output is correct
2 Correct 3 ms 4288 KB Output is correct
3 Correct 3 ms 4176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8272 KB Output is correct
2 Correct 4 ms 8128 KB Output is correct
3 Correct 4 ms 8272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 16720 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -