답안 #54807

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54807 2018-07-05T06:55:43 Z 윤교준(#1510) Calvinball championship (CEOI15_teams) C++11
70 / 100
39 ms 9040 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 = 1005;
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;
	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 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 588 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 684 KB Output is correct
2 Correct 3 ms 688 KB Output is correct
3 Correct 2 ms 820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 820 KB Output is correct
2 Correct 3 ms 820 KB Output is correct
3 Correct 2 ms 820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1112 KB Output is correct
2 Correct 2 ms 1160 KB Output is correct
3 Correct 3 ms 1160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2700 KB Output is correct
2 Correct 5 ms 2704 KB Output is correct
3 Correct 5 ms 2708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4632 KB Output is correct
2 Correct 7 ms 4640 KB Output is correct
3 Correct 8 ms 4640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 34 ms 8868 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 28 ms 8948 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 39 ms 9040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -