This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |