This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// 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;
C[B[N - 1 - x].first]++;
}
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;
}
# | 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... |