// soab
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define nl '\n'
#define fi first
#define se second
void io() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
const int maxn = 1e6 + 1;
int n, m, d;
pair<int,int> a[maxn];
bool check(int mid) {
int id = 0;
for(int i = 1; i <= n; i++) {
for(int j = 0; j < mid; j++) {
if(id >= m) break;
if(a[id].fi >= 0 && i - a[id].fi <= d) {
id++;
} else {
break;
}
}
}
return id == m;
}
signed main() {
io();
cin >> n >> d >> m;
for(int i = 0; i < m; i++) {
int t; cin >> t;
a[i] = {t, i + 1};
}
sort(a, a + m);
int l = 0, r = 1e9, ans;
while(l <= r) {
int mid = (l + r) / 2;
if(check(mid)) {
ans = mid;
r = mid - 1;
} else {
l = mid + 1;
}
}
cout << ans << nl;
int id = 0;
for(int i = 0; i < n; i++) {
if(id >= m) break;
for(int j = 0; j < ans; j++) {
if(id >= m) break;
cout << a[id].se << ' ';
id++;
}
cout << 0 << nl;
}
cout << 0 << nl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |