# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
875425 | lalig777 | Teams (CEOI11_tea) | C++14 | 385 ms | 81740 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>
#include <queue>
using namespace std;
int main(){
int n;
cin>>n;
vector<int>aux;
vector<pair<int,int> >children(n);
vector<vector<int> >teams;
vector<pair<int, int> >sizes;
for (int i=0; i<n; i++){
cin>>children[i].first;
children[i].second=i+1;
}sort(children.begin(), children.end());
sizes.push_back(make_pair(children[n-1].first, 0));
teams.push_back(aux);
teams[0].push_back(children[n-1].second);
int current_teams=1;
for (int i=n-2; i>=0; i--){
if (teams[current_teams-1].size()<sizes[current_teams-1].first){
teams[current_teams-1].push_back(children[i].second);
}else{
teams.push_back(aux);
teams[current_teams].push_back(children[i].second);
sizes.push_back(make_pair(children[i].first, current_teams));
current_teams++;
}
}int saltar=1e9;
if (sizes[current_teams-1].first>teams[current_teams-1].size()){
sizes[current_teams-1].first=teams[current_teams-1].size();
sort(sizes.begin(), sizes.end());
for (int j=0; j<teams[sizes[0].second].size(); j++){
sort(sizes.begin(), sizes.end());
teams[sizes[1].second].push_back(teams[sizes[0].second][j]);
sizes[1].first++;
sizes[0].first--;
}cout<<current_teams-1<<'\n';
saltar=sizes[0].second;
}else cout<<current_teams<<'\n';
for (int i=0; i<current_teams; i++){
if (i==saltar) continue;
cout<<teams[i].size();
for (int j=0; j<teams[i].size(); j++) cout<<" "<<teams[i][j];
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... |