#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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
2128 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
2884 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2574 ms |
247960 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
582 ms |
51356 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
270 ms |
18444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |