# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
875425 | 2023-11-19T16:35:30 Z | lalig777 | Teams (CEOI11_tea) | C++14 | 385 ms | 81740 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<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
# | 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 | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 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 | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 2 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 27 ms | 1884 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 2140 KB | Output is correct |
2 | Correct | 22 ms | 2264 KB | Output is correct |
3 | Correct | 30 ms | 2648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 250 ms | 14928 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 362 ms | 19316 KB | Output is correct |
2 | Correct | 317 ms | 81740 KB | Output is correct |
3 | Incorrect | 299 ms | 24972 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 385 ms | 18984 KB | Output is correct |
2 | Correct | 334 ms | 26816 KB | Output is correct |
3 | Incorrect | 308 ms | 23696 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |