// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define sz(x) int(x.size())
template<class T> using V = vector<T>;
int main() {
cin.tie(0)->sync_with_stdio(0);
// smallest L (MN <= L <= N) such that there are
// N % L values less than or equal N % L
// if x = N % L => L is a divisor of (N - x)
// minimum divisor of (N - x) such that
// it is greater than or equal to MN
int N; cin >> N;
V<int> A(N); for(auto& x : A) cin >> x;
int mn = *max_element(begin(A), end(A));
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));
map<int, int> C; for(auto x : A) C[x]++;
int amt = 0; V<int> pos(N);
for (int x = 0; x < N; x++) {
amt += C[x];
if (amt >= x) pos[x] = 1;
}
for (int L = mn; L <= N; L++) {
int x = N % L; if (pos[x]) {
V<V<int>> S = {};
if (x) {
S.push_back({});
for(int i = 0; i < x; i++) {
S.back().push_back(B.back().second);
B.pop_back();
}
}
for(int t = 0; t < (N-x)/L; t++) {
S.push_back({});
for(int i = 0; i < L; i++) {
S.back().push_back(B.back().second);
B.pop_back();
}
}
// cout << L << nl;
cout << sz(S) << nl;
for(auto v : S) {
cout << sz(v) << " ";
for(auto c : v) cout << c + 1 << " ";
cout << nl;
}
break;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 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 |
3 ms |
724 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
724 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
6636 KB |
Output is correct |
2 |
Incorrect |
28 ms |
6432 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
7324 KB |
Output is correct |
2 |
Incorrect |
26 ms |
6340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
326 ms |
56616 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
427 ms |
75720 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
477 ms |
77948 KB |
Output is correct |
2 |
Correct |
374 ms |
84804 KB |
Output is correct |
3 |
Incorrect |
431 ms |
77168 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |