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;
#define LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
#define all(x) x.begin(), x.end()
const int N=200005;
int32_t main() {
LCBorz;
int n;cin>>n;
vector<int> a[n];
vector<int> v(n+1);
for(int i=1;i<=n;i++){
cin>>v[i];
a[v[i]].push_back(i);
}
sort(all(v));
vector<int> dp(n+1);
vector<int> mx(n+1);
for(int i=1;i<=n;i++){
dp[i]=dp[mx[i-v[i]]]+1;
mx[i]=(dp[mx[i-1]]>dp[i]?mx[i-1]:i);
}
vector<vector<int>> ans;
int p=n;
while(p>0){
ans.push_back(vector<int>());
int t=mx[p-v[p]];
while(p>t){
ans.back().push_back(a[v[p]].back());
a[v[p]].pop_back();
p--;
}
}
cout<<dp[n]<<endl;
for(auto &i:ans){
cout<<i.size()<<' ';
for(int j:i){
cout<<j<<' ';
}
cout<<endl;
}
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... |