답안 #54815

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54815 2018-07-05T07:15:37 Z 윤교준(#1510) Calvinball championship (CEOI15_teams) C++11
70 / 100
12 ms 8572 KB
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[sz(V)-2])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmax(a,b) (a)=max((a),(b))
#define upmin(a,b) (a)=min((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 3505;
const int MOD = 1000007;

int dp[MAXN][MAXN];

int A[MAXN];

int Ans;
int N;

int main() {
    //freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(false);

	cin >> N;
	if(3500 < N) return -1;
	for(int i = 1; i <= N; i++) cin >> A[i];

	for(int i = 1; i <= N; i++) dp[0][i] = 1;
	for(int i = 1; i <= N; i++) for(int j = 1; j <= N; j++)
		dp[i][j] = (ll(dp[i-1][j]) * j + dp[i-1][j+1]) % MOD;

	for(int i = 2, mx = 1; i <= N; i++) {
		if(1 == A[i]) continue;
		Ans = (ll(dp[N-i][mx]) * (A[i]-1) + Ans) % MOD;
		upmax(mx, A[i]);
	}
	
	Ans++;
	cout << (((Ans % MOD) + MOD) % MOD) << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 2 ms 480 KB Output is correct
3 Correct 3 ms 480 KB Output is correct
4 Correct 3 ms 480 KB Output is correct
5 Correct 3 ms 480 KB Output is correct
6 Correct 2 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 592 KB Output is correct
2 Correct 2 ms 592 KB Output is correct
3 Correct 2 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 592 KB Output is correct
2 Correct 2 ms 592 KB Output is correct
3 Correct 2 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1000 KB Output is correct
2 Correct 2 ms 1004 KB Output is correct
3 Correct 2 ms 1008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3564 KB Output is correct
2 Correct 5 ms 3564 KB Output is correct
3 Correct 5 ms 3692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 8572 KB Output is correct
2 Correct 10 ms 8572 KB Output is correct
3 Correct 10 ms 8572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 8572 KB Execution failed because the return code was nonzero
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 8572 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 8572 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -