답안 #67896

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67896 2018-08-15T12:28:57 Z polyfish Calvinball championship (CEOI15_teams) C++14
70 / 100
378 ms 1080 KB
//I love armpit fetish

#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

const int MAX_N = 10002;
const int MOD = 1000007;

int n, a[MAX_N], max_a[MAX_N], f[2][MAX_N];

void enter() {
	cin >> n;
	for (int i=1; i<=n; ++i)
		cin >> a[i];
}

void solve() {
	int res = 0, cur = 0;
	for (int last=1; last<=n; ++last)
		f[cur][last] = 1;
	for (int i=1; i<=n; ++i)
		max_a[i] = max(max_a[i-1], a[i]);
	for (int i=n; i>=1; --i) {
		cur ^= 1;
		for (int nGroup=1; nGroup<i; ++nGroup) {
			f[cur][nGroup] = (f[cur^1][nGroup+1] + f[cur^1][nGroup] * nGroup) % MOD;
		}
		for (int j=1; j<a[i]; ++j)
			res = (res + f[cur^1][max(max_a[i-1], j)]) % MOD;
	}
	cout << res + 1;
}

int main() {
	//#define OFFLINE_JUDGE doraemon
	#ifdef OFFLINE_JUDGE
		freopen(FILE_NAME".inp", "r", stdin);
		freopen(FILE_NAME".out", "w", stdout);
	#endif
	ios::sync_with_stdio(0); cin.tie(0);
	enter();
	solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 4 ms 548 KB Output is correct
3 Correct 3 ms 548 KB Output is correct
4 Correct 3 ms 548 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Correct 3 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 640 KB Output is correct
2 Correct 3 ms 644 KB Output is correct
3 Correct 2 ms 776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 776 KB Output is correct
2 Correct 3 ms 776 KB Output is correct
3 Correct 3 ms 776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 776 KB Output is correct
2 Correct 2 ms 776 KB Output is correct
3 Correct 3 ms 776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 800 KB Output is correct
2 Correct 3 ms 820 KB Output is correct
3 Correct 4 ms 820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 820 KB Output is correct
2 Correct 3 ms 820 KB Output is correct
3 Correct 7 ms 820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 378 ms 1080 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 1080 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 131 ms 1080 KB Output isn't correct
2 Halted 0 ms 0 KB -