57172023-09-09 19:51:25kukkermanNegáló rendezés (55 pont)cpp14Accepted 55/5545ms5104 KiB
#include <iostream>
#include <vector>
#include <algorithm>

std::vector<int> beolvas(std::istream &in) {
	size_t n;
	in >> n;

	std::vector<int> v(n);
	for (auto i = 0u; i < n; i++) {
		in >> v[i];
	}

	return v;
}

void negalo_rendezes(std::vector<int> v) {
	static constexpr int m = 1000000007;

	std::sort(v.begin(), v.end());
	const auto n = v.size();

	int db = 1;
	auto i = 0u;
	for (; i < n && v[i] == v[0]; i++) {}

	while (i < n) {
		auto j = i;
		int x = db;
		for (; j < n && v[j] == v[i]; j++) {
			x = (x + db) % m;
		}

		db = x;
		i = j;
	}

	std::cout << db << std::endl;
}

int main() {
	auto v = beolvas(std::cin);
	negalo_rendezes(std::move(v));

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base55/55
1Accepted0/03ms1808 KiB
2Accepted0/045ms2760 KiB
3Accepted2/22ms2140 KiB
4Accepted2/22ms2216 KiB
5Accepted2/22ms2300 KiB
6Accepted2/23ms2544 KiB
7Accepted3/33ms2756 KiB
8Accepted2/23ms2968 KiB
9Accepted3/33ms2968 KiB
10Accepted3/339ms3608 KiB
11Accepted3/343ms3864 KiB
12Accepted3/337ms3964 KiB
13Accepted3/335ms4172 KiB
14Accepted3/341ms4388 KiB
15Accepted3/341ms4472 KiB
16Accepted3/343ms4468 KiB
17Accepted3/341ms4476 KiB
18Accepted3/343ms4596 KiB
19Accepted3/343ms4848 KiB
20Accepted3/341ms5020 KiB
21Accepted3/339ms4984 KiB
22Accepted3/339ms5104 KiB