# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
370026 | ijxjdjd | Teams (CEOI11_tea) | C++14 | 409 ms | 74920 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>
#define FR(i, N) for (int i = 0; i < int(N); i++)
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
int main() {
cin.tie(0);
cin.sync_with_stdio(0);
int N;
cin >> N;
vector<pair<int, int>> vec;
FR(i, N) {
int a;
cin >> a;
vec.emplace_back(a, i);
}
sort(all(vec));
vector<vector<int>> teams;
for (int j = N-1; j >= 0;) {
int k = vec[j].first;
if (j >= k-1) {
teams.push_back({});
while (k--> 0) {
teams.back().push_back(vec[j].second);
j--;
}
}
else {
while (k-->0 && j >= 0) {
int mn = 100000;
int mnI = -1;
for (int c = 0; c < teams.size(); c++) {
if (teams[c].size() < mn) {
mn = teams[c].size();
mnI = c;
}
}
teams[mnI].push_back(vec[j].second);
j--;
}
}
}
cout << teams.size() << '\n';
for (auto& a : teams) {
cout << a.size() << " ";
for (int j : a) {
cout << j+1<< " ";
}
cout << '\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... |