# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
227713 | dolphingarlic | Teams (CEOI11_tea) | C++14 | 377 ms | 27940 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 <bits/stdc++.h>
using namespace std;
pair<int, int> a[1000001];
vector<vector<int>> teams;
priority_queue<pair<int, int>> pq;
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i].first);
a[i].second = i;
}
sort(a + 1, a + n + 1);
while (n) {
if (a[n].first > n) {
int idx, sz;
tie(idx, sz) = pq.top();
pq.pop();
teams[idx].push_back(a[n--].second);
pq.push({idx, sz - 1});
} else {
int ptr = n;
teams.push_back({});
while (n - ptr != a[n].first) teams.back().push_back(a[ptr--].second);
pq.push({teams.size() - 1, -teams.back().size()});
n = ptr;
}
}
printf("%d\n", teams.size());
for (vector<int> i : teams) {
printf("%d", i.size());
for (int j : i) printf(" %d", j);
printf("\n");
}
return 0;
}
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... |