#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long int ll;
const int N=1e6+3;
int n,d,m;
pair<int,int> a[N];
bool chk(int x){
queue < pair<int,int> > q;
pair<int,int> tmp;
for(int i=0;i<m;i++)
q.push(make_pair(a[i].f,a[i].f+d));
for(int i=1;i<=n&&q.size();i++){
for(int j=0;j<x&&q.size();j++){
tmp=q.front();
q.pop();
if(tmp.s<i) return 0;
}
}
return (!q.size());
}
void out (int x){
queue <int> q;
int tmp;
for(int i=0;i<m;i++)
q.push(a[i].s);
for(int i=1;i<=n;i++){
for(int j=0;j<x&&q.size();j++){
tmp=q.front();
q.pop();
cout<<tmp<<" ";
}
cout<<0<<'\n';
}
return;
}
int main(){
cin.tie(NULL);
ios_base::sync_with_stdio(false);
cin>>n>>d>>m;
for(int i=0;i<m;i++){
cin>>a[i].f;
a[i].s=i+1;
}
sort(a,a+m);
int s=1,e=m,mid;
while(s<e){
mid=(s+e)/2;
if(chk(mid))
e=mid;
else
s=mid+1;
}
cout<<e<<'\n';
out(e);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
2552 KB |
Output isn't correct |
2 |
Incorrect |
39 ms |
2488 KB |
Output isn't correct |
3 |
Incorrect |
40 ms |
2624 KB |
Output isn't correct |
4 |
Incorrect |
40 ms |
2496 KB |
Output isn't correct |
5 |
Incorrect |
39 ms |
2424 KB |
Output isn't correct |
6 |
Incorrect |
39 ms |
2428 KB |
Output isn't correct |
7 |
Incorrect |
40 ms |
2496 KB |
Output isn't correct |
8 |
Incorrect |
39 ms |
2424 KB |
Output isn't correct |
9 |
Correct |
54 ms |
2680 KB |
Output is correct |
10 |
Correct |
54 ms |
2496 KB |
Output is correct |
11 |
Correct |
49 ms |
2468 KB |
Output is correct |
12 |
Correct |
100 ms |
4732 KB |
Output is correct |
13 |
Correct |
150 ms |
7044 KB |
Output is correct |
14 |
Correct |
205 ms |
9716 KB |
Output is correct |
15 |
Incorrect |
263 ms |
11748 KB |
Output isn't correct |
16 |
Correct |
321 ms |
14584 KB |
Output is correct |
17 |
Correct |
382 ms |
16900 KB |
Output is correct |
18 |
Correct |
436 ms |
18504 KB |
Output is correct |
19 |
Correct |
507 ms |
21100 KB |
Output is correct |
20 |
Correct |
383 ms |
17124 KB |
Output is correct |