Submission #875441

#TimeUsernameProblemLanguageResultExecution timeMemory
875441lalig777Teams (CEOI11_tea)C++14
40 / 100
2541 ms19132 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<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[0].first>teams[0].second.size()){ teams[0].second.push_back(children[i].second); }else{ if (children[i].first>i+1){ teams[0].first++; teams[0].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++; } }sort(teams.begin(), teams.end()); }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)

tea.cpp: In function 'int main()':
tea.cpp:21:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   if (teams[0].first>teams[0].second.size()){
#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...