Submission #906231

# Submission time Handle Problem Language Result Execution time Memory
906231 2024-01-13T19:54:14 Z MilosMilutinovic Teams (CEOI11_tea) C++14
30 / 100
613 ms 117136 KB
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = array<int, 2>;
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
const int MAX = 1000010;
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	set<pair<int, int>> st;
	for (int i = 0; i < n; i++) {
		st.emplace(a[i], i);
	}
	vector<vector<int>> teams;
	while (sz(st) > 0) {
		auto it = prev(st.end());
		int v = it->first;
		if (v > sz(st)) break;
		teams.push_back({});
		while (v--) {
			teams.back().push_back(prev(st.end())->second);
			st.erase(prev(st.end()));
		}
	}
	set<pair<int, int>> t;
	for (int i = 0; i < sz(teams); i++) {
		t.emplace(sz(teams[i]), i);
	}
	while (sz(st) > 0) {
		auto it = t.begin();
		int idx = it->second;
		t.erase(it);
		teams[idx].push_back(st.begin()->second);
		st.erase(st.begin());
		t.emplace(sz(teams[idx]), idx);
	}
	cout << sz(teams) << "\n";
	for (int i = 0; i < sz(teams); i++) {
		cout << sz(teams[i]) << " ";
		for (int j = 0; j < sz(teams[i]); j++) {
			cout << teams[i][j] + 1 << " ";
		}
		cout << "\n";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 5460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 6052 KB Output is correct
2 Correct 22 ms 5152 KB Output is correct
3 Correct 29 ms 5976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 270 ms 46668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 416 ms 63448 KB Output is correct
2 Correct 612 ms 117136 KB Output is correct
3 Incorrect 396 ms 61488 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 613 ms 67364 KB Output is correct
2 Correct 347 ms 62284 KB Output is correct
3 Incorrect 354 ms 60500 KB Output isn't correct
4 Halted 0 ms 0 KB -