#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, int> > teamsSize;
vector<int> teams[MAXN];
int cnt = 0;
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;
for (int i = ini; i <= fim; i++) teams[cnt].push_back(Indices[i]);
teamsSize.emplace(teams[cnt].size(), cnt);
cnt++;
i -= (v[Indices[i]] - 1);
}
else
{
int smallTeam = (*teamsSize.begin()).second;
teamsSize.erase(teamsSize.begin());
teams[smallTeam].push_back(Indices[i]);
teamsSize.emplace(teams[smallTeam].size(), smallTeam);
}
}
cout << cnt;
for (auto it : teamsSize)
{
cout << '\n';
cout << (it.first);
for (auto i : teams[it.second]) cout << " " << i;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
23756 KB |
Output is correct |
2 |
Correct |
12 ms |
23756 KB |
Output is correct |
3 |
Correct |
14 ms |
23804 KB |
Output is correct |
4 |
Correct |
13 ms |
23756 KB |
Output is correct |
5 |
Correct |
12 ms |
23756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
23780 KB |
Output is correct |
2 |
Correct |
12 ms |
23756 KB |
Output is correct |
3 |
Correct |
13 ms |
23812 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
23724 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
23884 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
23884 KB |
Output is correct |
2 |
Correct |
14 ms |
23928 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
25324 KB |
Output is correct |
2 |
Correct |
35 ms |
25424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
25448 KB |
Output is correct |
2 |
Correct |
27 ms |
25548 KB |
Output is correct |
3 |
Correct |
33 ms |
25384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
180 ms |
38316 KB |
Output is correct |
2 |
Correct |
181 ms |
40372 KB |
Output is correct |
3 |
Correct |
181 ms |
38864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
249 ms |
42504 KB |
Output is correct |
2 |
Correct |
558 ms |
118712 KB |
Output is correct |
3 |
Correct |
205 ms |
45600 KB |
Output is correct |
4 |
Correct |
258 ms |
40660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
258 ms |
42552 KB |
Output is correct |
2 |
Correct |
198 ms |
42544 KB |
Output is correct |
3 |
Correct |
215 ms |
43256 KB |
Output is correct |
4 |
Correct |
298 ms |
42728 KB |
Output is correct |