Submission #530152

#TimeUsernameProblemLanguageResultExecution timeMemory
530152ThegeekKnight16Teams (CEOI11_tea)C++17
0 / 100
2580 ms242544 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000010; int v[MAXN]; int Indices[MAXN]; /*struct team { int ini; int fim; bool operator<(team outro) { return fim - ini < outro.fim - outro.ini; } };*/ set<pair<int, pair<int, int> > > teams; bool cmp(int a, int b) { return v[a] < v[b]; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N; cin >> N; for (int i = 1; i <= N; i++) {cin >> v[i]; Indices[i] = i;} sort(Indices+1, Indices+N+1, cmp); for (int i = N; i > 0; i--) { if (i - (v[Indices[i]] - 1) > 0) { int ini = i - (v[Indices[i]] - 1); int fim = i; teams.insert(make_pair(fim - ini, make_pair(ini, fim) ) ); i -= (v[Indices[i]] - 1); } else { pair<int, int> smallTeam; smallTeam = (*teams.begin()).second; teams.erase(teams.begin()); smallTeam.first = i; teams.insert(make_pair(smallTeam.second - smallTeam.first, smallTeam)); } } cout << teams.size(); for (auto it : teams) { pair<int, int> curTeam = it.second; cout << '\n'; cout << (it.first + 1); for (int i = curTeam.first; i <= curTeam.second; i++) cout << " " << Indices[i]; } }
#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...