// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
template<class T> using V = vector<T>;
int main() {
cin.tie(0)->sync_with_stdio(0);
int N; cin >> N;
V<int> A(N); for(auto& x : A) cin >> x;
V<pair<int, int>> B; for(int i = 0; i < N; i++) B.push_back(make_pair(A[i], i));
sort(rbegin(B), rend(B));
V<V<int>> C;
V<int> ex;
for(int i = 0; i < N; i++) {
int left = N - i;
if (left < B[i].first) {
ex.push_back(B[i].second);
} else {
int r = i + B[i].first;
C.push_back({});
for(int x = i; x < r; x++) C.back().push_back(B[x].second);
i = r - 1;
}
}
int lo = 0, hi = N;
while(lo < hi) {
int mid = (lo + hi) / 2;
int have = 0, need = size(ex);
for(auto v : C) have += mid - size(v);
if (have >= need) hi = mid;
else lo = mid + 1;
}
int mx = lo;
cout << size(C) << nl;
for(auto v : C) {
while(size(ex) && int(size(v)) < mx) v.push_back(ex.back()), ex.pop_back();
cout << size(v) << " ";
for(auto x : v) cout << x + 1 << " ";
cout << nl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
244 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
324 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
496 KB |
Output is correct |
2 |
Correct |
2 ms |
588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
2340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
2656 KB |
Output is correct |
2 |
Correct |
18 ms |
2492 KB |
Output is correct |
3 |
Correct |
23 ms |
2896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
169 ms |
18088 KB |
Output is correct |
2 |
Incorrect |
162 ms |
21704 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
224 ms |
24216 KB |
Output is correct |
2 |
Correct |
589 ms |
78684 KB |
Output is correct |
3 |
Incorrect |
237 ms |
28640 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
259 ms |
28184 KB |
Output is correct |
2 |
Correct |
162 ms |
34816 KB |
Output is correct |
3 |
Correct |
211 ms |
27616 KB |
Output is correct |
4 |
Correct |
248 ms |
29488 KB |
Output is correct |