Submission #875419

#TimeUsernameProblemLanguageResultExecution timeMemory
875419gutzzyTeams (CEOI11_tea)C++14
0 / 100
440 ms37380 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<pair<int,int>> a(n); for(int i=0;i<n;i++){ cin >> a[i].first; a[i].second = i+1; } sort(a.begin(),a.end()); reverse(a.begin(),a.end()); int pos = 0; vector<vector<pair<int,int>>> teams; vector<pair<int,int>> rest; while(pos<n){ if(pos+a[pos].first<n){ vector<pair<int,int>> temp(a.begin()+pos,a.begin()+pos+a[pos].first); teams.push_back(temp); } else if(pos+a[pos].first==n){ vector<pair<int,int>> temp(a.begin()+pos,a.end()); teams.push_back(temp); } else{ rest = vector<pair<int,int>>(a.begin()+pos,a.end()); } pos+=a[pos].first; } /* cout << "teams: "<<endl; for(auto t:teams){ for(auto m:t){ cout << m.first << " " << m.second << endl; } cout << endl; } cout << "rest: "<<endl; for(auto m:rest){ cout << m.first << " " << m.second << endl; } cout << "ans: "<<endl; */ if(rest.size()!=0){ reverse(rest.begin(),rest.end()); pos = 0; int l_rest = rest.size(); vector<pair<int,int>> rest2; while(pos<l_rest){ if(pos+rest[pos].first<l_rest){ vector<pair<int,int>> temp(rest.begin()+pos,rest.begin()+pos+rest[pos].first); teams.push_back(temp); } else if(pos+rest[pos].first==l_rest){ vector<pair<int,int>> temp(rest.begin()+pos,rest.end()); teams.push_back(temp); } else{ vector<pair<int,int>> rest2(rest.begin()+pos,rest.end()); } pos+=rest[pos].first; } for(auto r:rest2){ int best = 0; int cur_best = 1e9; int i=0; for(auto team:teams){ if(team.size()>=r.first-1 and team.size()<cur_best){ cur_best = team.size(); best = i; } i++; } teams[best].push_back(r); } } // print answer cout << teams.size() << endl; for(auto team:teams){ cout << team.size() << " "; for(auto m:team) cout << m.second << " "; cout << endl; } return 0; }

Compilation message (stderr)

tea.cpp: In function 'int main()':
tea.cpp:72:31: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   72 |                 if(team.size()>=r.first-1 and team.size()<cur_best){
      |                    ~~~~~~~~~~~^~~~~~~~~~~
tea.cpp:72:58: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   72 |                 if(team.size()>=r.first-1 and team.size()<cur_best){
      |                                               ~~~~~~~~~~~^~~~~~~~~
#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...