#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
int n, d, m;
cin >> n >> d >> m;
vector<int> a(m + 1);
for(int i = 1; i <= m; i++) {
cin >> a[i];
}
sort(a.begin() + 1, a.end());
int l = 1, r = m, ans = - 1;
while(l <= r) {
int mid = (l + r) / 2;
set<int> s;
int ok = 1;
for(int i = 1; i <= m; i++) {
if(s.size() < mid) {
s.insert(a[i] + 1);
}
else {
if(a[i] >= *s.begin()) {
auto it = s.begin();
s.erase(it);
s.insert(a[i] + 1);
}
else {
ok = 0;
break;
}
}
}
if(ok) {
r = mid - 1;
ans = mid;
}
else {
l = mid + 1;
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |