#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];
}
}
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
272 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
26 ms |
2080 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
35 ms |
2840 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2580 ms |
242544 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
590 ms |
51308 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
271 ms |
18616 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |