#include <bits/stdc++.h>
using namespace std;
int n, d, m, in, l=0, r=1e9, mid;
vector<int> t[100010];
bool solve(int num) {
queue<int> q;
for(int i=1; i<=n; i++) {
for(int j: t[i]) q.push(i);
for(int j=1; j<=num && q.size(); j++) q.pop();
if(q.size() && i-q.front() > d) {
return 0;
}
}
return 1;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> d >> m;
for(int i=1; i<=m; i++) {
cin >> in;
t[in].push_back(i);
}
while(l < r) {
mid = (l+r)>>1;
if(solve(mid)) {
r = mid;
} else {
l = mid+1;
}
}
return 0;
queue<int> q;
for(int i=1; i<=n; i++) {
for(int j: t[i]) q.push(j);
for(int j=1; j<=l && q.size(); j++) {
cout << q.front() << " ";
q.pop();
}
cout << "0\n";
}
return 0;
}
Compilation message
jobs.cpp: In function 'bool solve(int)':
jobs.cpp:11:17: warning: unused variable 'j' [-Wunused-variable]
11 | for(int j: t[i]) q.push(i);
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
15 ms |
3544 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
15 ms |
3548 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
16 ms |
3556 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
16 ms |
3548 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
15 ms |
3544 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
15 ms |
3548 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
15 ms |
3544 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
16 ms |
3548 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
26 ms |
3424 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
24 ms |
3416 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
15 ms |
3160 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
28 ms |
3676 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
42 ms |
4952 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
75 ms |
5424 KB |
Unexpected end of file - int32 expected |
15 |
Incorrect |
66 ms |
5712 KB |
Unexpected end of file - int32 expected |
16 |
Incorrect |
96 ms |
6516 KB |
Unexpected end of file - int32 expected |
17 |
Incorrect |
126 ms |
8188 KB |
Unexpected end of file - int32 expected |
18 |
Incorrect |
105 ms |
7188 KB |
Unexpected end of file - int32 expected |
19 |
Incorrect |
126 ms |
7260 KB |
Unexpected end of file - int32 expected |
20 |
Incorrect |
115 ms |
7948 KB |
Unexpected end of file - int32 expected |