# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
875443 | lalig777 | Teams (CEOI11_tea) | C++14 | 371 ms | 79768 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<pair<int, vector<int> > >teams;
for (int i=0; i<n; i++){
cin>>children[i].first;
children[i].second=i+1;
}sort(children.begin(), children.end());
teams.push_back(make_pair(children[n-1].first, aux));
teams[0].second.push_back(children[n-1].second);
int current_teams=1;
for (int i=n-2; i>=0; i--){
if (teams[current_teams-1].first>teams[current_teams-1].second.size()){
teams[current_teams-1].second.push_back(children[i].second);
}else{
if (children[i].first>i+1){
sort(teams.begin(), teams.end());
reverse(teams.begin(), teams.end());
teams[current_teams-1].first++;
teams[current_teams-1].second.push_back(children[i].second);
}else{
teams.push_back(make_pair(children[i].first, aux));
teams[current_teams].second.push_back(children[i].second);
current_teams++;
}
}
}cout<<current_teams<<'\n';
for (int i=0; i<current_teams; i++){
cout<<teams[i].first;
for (int j=0; j<teams[i].first; j++) cout<<" "<<teams[i].second[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... |