Submission #403650

# Submission time Handle Problem Language Result Execution time Memory
403650 2021-05-13T10:47:12 Z saleh Calvinball championship (CEOI15_teams) C++17
70 / 100
379 ms 972 KB
#include <bits/stdc++.h>


using namespace std;


const int MAXN = 10 * 1000 + 23, D = 1000 * 1000 + 7;















int dp[2][MAXN], a[MAXN], n, cnt[MAXN], jav;



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	{
		set<int> s;
		for (int i = 0; i < n; i++) {
			s.insert(a[i]);
			cnt[i] = s.size();
		}
	}
	fill(dp[1], dp[1] + n, 1);
	for (int i = 0; i < n - 1; i++) {
		for (int j = 1; j < n - 1; j++) dp[i & 1][j] = (dp[1 - (i & 1)][j] * j % D + dp[1 - (i & 1)][j + 1]) % D;
		int j = n - i - 1;
		jav += (a[j] - 1) * dp[1 - (i & 1)][cnt[j - 1]] % D;
		jav %= D;
	}
	cout << jav + 1;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 5 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 339 ms 972 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 92 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 379 ms 488 KB Output isn't correct
2 Halted 0 ms 0 KB -