// 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) {
assert(sz(v) >= A[c]);
cout << c + 1 << " ";
}
cout << nl;
}
break;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
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 |
3 ms |
708 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
6732 KB |
Output is correct |
2 |
Incorrect |
28 ms |
6456 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
7460 KB |
Output is correct |
2 |
Incorrect |
26 ms |
6296 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
315 ms |
57360 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
433 ms |
77456 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
451 ms |
80216 KB |
Output is correct |
2 |
Correct |
311 ms |
85648 KB |
Output is correct |
3 |
Incorrect |
400 ms |
77664 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |