#include "bits/stdc++.h"
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
*/
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
using ll = long long;
const int mod = 1e9+7;
vector<array<int, 2>> v;
int n, m, d;
bool chk(int x) {
int k = 0;
for (int i = 1; i <= n; ++i) {
for (int j = 0; j < x and k < m; ++j) {
if (i > v[k][0] + d) return false;
if (i >= v[k][0]) ++k;
else break;
}
}
return 1;
}
void solve(int tc) {
cin >> n >> d >> m;
v.resize(m);
for (int i = 0; i < m; ++i) {
cin >> v[i][0];
v[i][1] = i;
}
sort(all(v));
int lo = 1, hi = m+1;
int ans;
while (lo < hi) {
int mid = lo + (hi - lo) / 2;
cout << "mid : " << mid << '\n';
if (chk(mid)) {
ans = mid;
hi = mid;
} else lo = mid + 1;
}
cout << ans << '\n';
int x = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < ans and x < m; ++j) {
cout << v[x++][1] + 1 << " ";
}
cout << "0\n";
}
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int tc = 1;
//cin >> tc;
for (int i = 1; i <= tc; ++i) solve(i);
return 0;
}
Compilation message
jobs.cpp: In function 'void solve(int)':
jobs.cpp:48:20: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
48 | cout << ans << '\n';
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
2028 KB |
Expected integer, but "mid" found |
2 |
Incorrect |
25 ms |
2156 KB |
Expected integer, but "mid" found |
3 |
Incorrect |
25 ms |
2028 KB |
Expected integer, but "mid" found |
4 |
Incorrect |
25 ms |
2028 KB |
Expected integer, but "mid" found |
5 |
Incorrect |
26 ms |
2028 KB |
Expected integer, but "mid" found |
6 |
Incorrect |
24 ms |
2028 KB |
Expected integer, but "mid" found |
7 |
Incorrect |
25 ms |
2028 KB |
Expected integer, but "mid" found |
8 |
Incorrect |
25 ms |
2028 KB |
Expected integer, but "mid" found |
9 |
Incorrect |
37 ms |
2156 KB |
Expected integer, but "mid" found |
10 |
Incorrect |
36 ms |
2156 KB |
Expected integer, but "mid" found |
11 |
Incorrect |
32 ms |
2156 KB |
Expected integer, but "mid" found |
12 |
Incorrect |
66 ms |
3948 KB |
Expected integer, but "mid" found |
13 |
Incorrect |
101 ms |
5868 KB |
Expected integer, but "mid" found |
14 |
Incorrect |
139 ms |
8172 KB |
Expected integer, but "mid" found |
15 |
Incorrect |
176 ms |
9580 KB |
Expected integer, but "mid" found |
16 |
Incorrect |
207 ms |
11372 KB |
Expected integer, but "mid" found |
17 |
Incorrect |
258 ms |
14188 KB |
Expected integer, but "mid" found |
18 |
Incorrect |
281 ms |
15212 KB |
Expected integer, but "mid" found |
19 |
Incorrect |
315 ms |
17388 KB |
Expected integer, but "mid" found |
20 |
Incorrect |
244 ms |
14188 KB |
Expected integer, but "mid" found |