Submission #1081731

# Submission time Handle Problem Language Result Execution time Memory
1081731 2024-08-30T09:41:42 Z 42kangaroo Calvinball championship (CEOI15_teams) C++17
40 / 100
283 ms 604 KB
//
// Created by 42kangaroo on 30/08/2024.
//
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

constexpr ll mod = 1e6 + 7;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	vector<int> nuD(n);
	int act = 1;
	for (int i = 0; i < n; ++i) {
		if (a[i] > act) act++;
		nuD[i] = act;
	}
	vector<ll> dp(n + 1, 1), dpN(n + 1, 0);
	ll res = 1;
	for (int i = n - 1; i >= 0; --i) {
		res += (dp[nuD[i] - 1] * (a[i] - 1))%mod;
		res %= mod;
		for (int j = 0; j < n; ++j) {
			dpN[j] = (dp[j] * j)%mod + dp[j + 1];
			dpN[j] %= mod;
		}
		swap(dp, dpN);
	}
	cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 259 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 283 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -