# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
530162 | LFFB | Teams (CEOI11_tea) | C++14 | 263 ms | 20968 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
const int MAX_N = 1000000 + 10;
int n;
std::pair<int, int> input[MAX_N];
bool sortingFunction(std::pair<int, int> a, std::pair<int, int> b) {
return a.first > b.first;
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
int x;
scanf("%d", &x);
input[i] = std::make_pair(x, i);
}
std::sort(input, input + n, sortingFunction);
std::vector<int> teamSize;
std::vector<std::vector<int>> team;
std::vector<int> minimum;
int index = 0;
int remaining = n;
teamSize.push_back(1);
team.push_back(std::vector<int>());
team[0].push_back(input[0].second);
minimum.push_back(input[0].first);
for (int i = 1; i < n; i++) {
remaining--;
if (minimum[index] > teamSize[index]) {
teamSize[index]++;
team[index].push_back(input[i].second);
} else if (remaining >= input[i].first) {
teamSize.push_back(1);
team.push_back(std::vector<int>());
minimum.push_back(input[i].first);
index++;
team[index].push_back(input[i].second);
} else {
teamSize[index]++;
team[index].push_back(input[i].second);
}
}
printf("%d\n", (int)team.size());
for (std::vector<int> t : team) {
printf("%d ", (int)t.size());
for (int x : t) printf("%d ", x + 1);
printf("\n");
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |