Submission #875443

# Submission time Handle Problem Language Result Execution time Memory
875443 2023-11-19T17:16:24 Z lalig777 Teams (CEOI11_tea) C++14
80 / 100
371 ms 79768 KB
#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

tea.cpp: In function 'int main()':
tea.cpp:21:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   if (teams[current_teams-1].first>teams[current_teams-1].second.size()){
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 1752 KB Output is correct
2 Correct 22 ms 1844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2132 KB Output is correct
2 Correct 21 ms 1928 KB Output is correct
3 Correct 29 ms 1908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 266 ms 14800 KB Output is correct
2 Correct 216 ms 16584 KB Output is correct
3 Correct 267 ms 15696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 345 ms 19044 KB Output is correct
2 Correct 298 ms 79768 KB Output is correct
3 Correct 297 ms 21940 KB Output is correct
4 Correct 310 ms 21968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 371 ms 18988 KB Output is correct
2 Correct 324 ms 19124 KB Output is correct
3 Correct 302 ms 19772 KB Output is correct
4 Correct 344 ms 19144 KB Output is correct