Submission #448029

# Submission time Handle Problem Language Result Execution time Memory
448029 2021-07-28T14:32:40 Z minoum Calvinball championship (CEOI15_teams) C++17
0 / 100
91 ms 65540 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long int ll;


const int MAXN = 10001;
const ll md = 1e6+7;

int n, a[MAXN], pt = 0;
int dp[MAXN][MAXN], ans = 0;

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	for(int i = 1; i < MAXN; i++) dp[1][i] = i+1, dp[0][i] = 1ll;
	for(int i = 2; i < MAXN; i++)
		for(ll j = 1; j < MAXN; j++){
			dp[i][j] = (j*(ll)dp[i-1][j])%md;
			if(j+1 < MAXN) dp[i][j] = ((ll)dp[i][j]+dp[i-1][j+1]>=md?(ll)dp[i][j]+(ll)dp[i-1][j+1]-md:(ll)dp[i][j]+(ll)dp[i-1][j+1]);
		}
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	pt = 1;
	for(int i = 0; i < n; i++){
		if(a[i]==1) continue;
		ll tmp = (ll)a[i]-1ll;
		tmp = (tmp*dp[n-i-1][pt])%md;
		ans = (ans+tmp)%md;
		if(a[i]==pt+1) pt++;
	}
	cout << (ans+1)%md << '\n';
	return 0; 
}
# Verdict Execution time Memory Grader output
1 Runtime error 86 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 84 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 87 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 89 ms 65540 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 87 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 91 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 88 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 90 ms 65540 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 87 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 88 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -