Submission #875446

#TimeUsernameProblemLanguageResultExecution timeMemory
875446ElenaBMTeams (CEOI11_tea)C++17
0 / 100
469 ms262144 KiB
#include <bits/stdc++.h> #define x first #define y second using namespace std; int main() { int n; cin>> n; vector<int>a, s(1); vector<pair<int,int>>v(n); vector<vector<int>>teams(1); for (int i = 0; i < n; ++i){ int u; cin>> u; v[i] = {u, i+1}; } sort(v.begin(), v.end(), greater()); teams[0].push_back(v[0].y); s[0] = v[0].x -1; int cur = 0; for (int i = 1; i <n; ++i){ if (s[cur] > 0){ teams[cur].push_back(v[i].y); s[cur]--; } else{ if(v[i].x-1 > n - i){//si el tamaño requerido por el mayor jugador es mayor a la cantidad de jugadores por emparejar --> prevenir for (int u = i; u < n; ++i){ teams[cur].push_back(v[u].y); } break; } teams.push_back(vector<int>()); cur++; teams[cur].push_back(v[i].y); s.push_back(v[i].x-1); } } cout<< (int)teams.size() << '\n'; for (int i = 0; i < (int) teams.size(); ++i){ cout<< (int) teams[i].size()<< ' '; for (int j = 0; j < (int)teams[i].size(); ++j){ cout<< teams[i][j]<< ' '; } cout<< '\n'; } return 0; }
#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...