Submission #448027

# Submission time Handle Problem Language Result Execution time Memory
448027 2021-07-28T14:30:01 Z minoum Calvinball championship (CEOI15_teams) C++17
70 / 100
9 ms 8336 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long int ll;

#define int ll

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

ll n, a[MAXN], pt = 0;
ll 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(ll i = 2; i < MAXN; i++)
		for(ll j = 1; j < MAXN; j++){
			dp[i][j] = (j*dp[i-1][j])%md;
			if(j+1 < MAXN) dp[i][j] += dp[i-1][j+1], dp[i][j] = (dp[i][j]>=md?dp[i][j]-md:dp[i][j]);
		}
	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 Correct 7 ms 8184 KB Output is correct
2 Correct 7 ms 8156 KB Output is correct
3 Correct 7 ms 8232 KB Output is correct
4 Correct 9 ms 8140 KB Output is correct
5 Correct 7 ms 8140 KB Output is correct
6 Correct 7 ms 8140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8140 KB Output is correct
2 Correct 7 ms 8104 KB Output is correct
3 Correct 8 ms 8148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8140 KB Output is correct
2 Correct 7 ms 8224 KB Output is correct
3 Correct 8 ms 8108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8140 KB Output is correct
2 Correct 7 ms 8140 KB Output is correct
3 Correct 7 ms 8140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8140 KB Output is correct
2 Correct 8 ms 8336 KB Output is correct
3 Correct 7 ms 8136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8124 KB Output is correct
2 Correct 7 ms 8224 KB Output is correct
3 Correct 7 ms 8224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 8200 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 8240 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 8140 KB Output isn't correct
2 Halted 0 ms 0 KB -