#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n; cin >> n; pair<int, int> A[n + 1];
for (int i = 1; i <= n; i++) cin >> A[i].first, A[i].second = i;
sort(A + 1, A + n + 1);
auto maxTeams = [&](int mxsz, bool get){
int dp[n + 1], sz[n + 1];
memset(dp, -0x3f, sizeof(dp)); dp[0] = 0;
for (int i = 1; i <= n; i++){
int l = max(i - mxsz, 0), r = i - A[i].first;
if (l <= r) dp[i] = dp[r] + 1, sz[i] = i - r;
}
if (get){
cout<<dp[n]<<"\n";
for (int pos = n; pos; pos -= sz[pos]){
cout<<sz[pos]<<" ";
for (int i = pos; i > pos - sz[pos]; i--) cout<<A[i].second<<" ";
cout<<"\n";
}
}
return dp[n];
};
int L = 1, H = n, mx = maxTeams(1e9, 0);
while (L < H){
int M = (L + H) / 2;
(maxTeams(M, 0) == mx) ? H = M : L = M + 1;
}
maxTeams(H, 1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Execution timed out |
2547 ms |
77216 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2593 ms |
92100 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2583 ms |
86500 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2592 ms |
88172 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2567 ms |
84720 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2570 ms |
90032 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2559 ms |
90636 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2583 ms |
97764 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2540 ms |
92076 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2524 ms |
97580 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |