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;
typedef long long ll;
const int maxn = 1e6 + 10;
pair<int,int> a[maxn];
bool mark[maxn];
int main(){
ios_base::sync_with_stdio(false);
int n;
cin >> n;
for (int i = 1; i <= n; i++){
int x;
cin >> x;
a[i] = {x, i};
}
sort(a + 1, a + n + 1);
int t = 0;
int now = n;
while (now > 1){
if (a[now].first > now){
now --;
continue;
}
mark[now] = 1;
t ++;
now -= a[now].first;
}
cout << t << endl;
int last = 0;
for (int i = 1; i <= n; i++){
if (mark[i]){
cout << i - last << ' ';
for (int j = last + 1; j <= i; j++)
cout << a[j].second << ' ';
last = i;
cout << '\n';
}
}
}
# | 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... |