Submission #875425

#TimeUsernameProblemLanguageResultExecution timeMemory
875425lalig777Teams (CEOI11_tea)C++14
30 / 100
385 ms81740 KiB
#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)

tea.cpp: In function 'int main()':
tea.cpp:23:36: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |   if (teams[current_teams-1].size()<sizes[current_teams-1].first){
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tea.cpp:32:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  if (sizes[current_teams-1].first>teams[current_teams-1].size()){
tea.cpp:35:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   for (int j=0; j<teams[sizes[0].second].size(); j++){
      |                 ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tea.cpp:46:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   for (int j=0; j<teams[i].size(); j++) cout<<" "<<teams[i][j];
      |                 ~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...