#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() && d+q.front() == i) {
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;
}
}
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 |
21 ms |
4056 KB |
Output isn't correct |
2 |
Incorrect |
19 ms |
4468 KB |
Output isn't correct |
3 |
Incorrect |
19 ms |
4060 KB |
Output isn't correct |
4 |
Incorrect |
20 ms |
4056 KB |
Output isn't correct |
5 |
Incorrect |
19 ms |
4060 KB |
Output isn't correct |
6 |
Incorrect |
19 ms |
4148 KB |
Output isn't correct |
7 |
Incorrect |
22 ms |
4016 KB |
Output isn't correct |
8 |
Incorrect |
21 ms |
4060 KB |
Output isn't correct |
9 |
Incorrect |
27 ms |
4232 KB |
Expected EOLN |
10 |
Incorrect |
27 ms |
4180 KB |
Expected EOLN |
11 |
Incorrect |
19 ms |
3924 KB |
Expected EOLN |
12 |
Incorrect |
37 ms |
5008 KB |
Expected EOLN |
13 |
Incorrect |
56 ms |
6992 KB |
Expected EOLN |
14 |
Incorrect |
89 ms |
8260 KB |
Expected EOLN |
15 |
Incorrect |
88 ms |
9044 KB |
Expected EOLN |
16 |
Incorrect |
132 ms |
10872 KB |
Expected EOLN |
17 |
Incorrect |
149 ms |
12816 KB |
Expected EOLN |
18 |
Incorrect |
140 ms |
12624 KB |
Expected EOLN |
19 |
Incorrect |
168 ms |
13496 KB |
Expected EOLN |
20 |
Incorrect |
153 ms |
12788 KB |
Expected EOLN |