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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int VAL=1000005;
int N, i, j, nr, M;
pair <int, int> elev[VAL];
vector <int> V[VAL];
vector <int> :: iterator it;
bool cmp(pair <int, int> A, pair <int, int> B)
{
return A.first>B.first;
}
int main()
{
cin >> N;
for (i=1; i<=N; i++)
{
cin >> elev[i].first;
elev[i].second=i;
}
sort(elev+1, elev+N+1, cmp);
for (i=1; i<=N; i++)
{
if (nr>0)
{
nr--;
V[M].push_back(elev[i].second);
}
else
{
if (elev[i].first<=N-i+1)
{
M++;
V[M].push_back(elev[i].second);
nr=elev[i].first-1;
}
else
V[M].push_back(elev[i].second);
}
}
cout << M << '\n';
for (i=1; i<=M; i++)
{
cout << V[i].size() << " ";
for (it=V[i].begin(); it!=V[i].end(); it++)
cout << *it << " ";
cout << '\n';
}
return 0;
}
# | 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... |