#include <bits/stdc++.h>
#define f first
#define se second
using namespace std;
int N,M,D;
pair<int,int> s[1000001];
vector<int> st[100001];
bool check(int T){
if(T>=M)return true;
if(T==0)return false;
int j=0;
for(int i=0;i<M;i++){
if(i%T==0)j++;
j=max(j,s[i].f);
if(s[i].f+D<j)return false;
}
return true;
}
int main(){
cin>>N>>D>>M;
for(int i=0;i<M;i++){
cin>>s[i].f;
s[i].se=i+1;
}
sort(s,s+M);
int x=-1;
for(int b=M;b>=1;b/=2)
while(!check(x+b))x+=b;
cout<<x+1<<endl;
x++;
int j=0;
for(int i=0;i<M;i++){
if(i%x==0)j++;
j=max(j,s[i].f);
if(s[i].f+D<j)st[j].push_back(s[i].se);
}
for(int i=0;i<N;i++){
for(int z=0;z<st[i].size();z++)cout<<st[i][z]<<" ";
cout<<0<<endl;
}
}
Compilation message
jobs.cpp: In function 'int main()':
jobs.cpp:41:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int z=0;z<st[i].size();z++)cout<<st[i][z]<<" ";
~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
73 ms |
3448 KB |
Output is correct |
2 |
Correct |
73 ms |
3576 KB |
Output is correct |
3 |
Correct |
74 ms |
3532 KB |
Output is correct |
4 |
Correct |
75 ms |
3448 KB |
Output is correct |
5 |
Correct |
75 ms |
3448 KB |
Output is correct |
6 |
Correct |
72 ms |
3448 KB |
Output is correct |
7 |
Correct |
75 ms |
3576 KB |
Output is correct |
8 |
Correct |
72 ms |
3496 KB |
Output is correct |
9 |
Correct |
330 ms |
3704 KB |
Output is correct |
10 |
Correct |
330 ms |
3732 KB |
Output is correct |
11 |
Correct |
62 ms |
3448 KB |
Output is correct |
12 |
Correct |
126 ms |
4216 KB |
Output is correct |
13 |
Correct |
177 ms |
4984 KB |
Output is correct |
14 |
Correct |
296 ms |
5960 KB |
Output is correct |
15 |
Incorrect |
291 ms |
6648 KB |
Output isn't correct |
16 |
Correct |
416 ms |
7472 KB |
Output is correct |
17 |
Correct |
490 ms |
8236 KB |
Output is correct |
18 |
Correct |
500 ms |
9108 KB |
Output is correct |
19 |
Incorrect |
804 ms |
9888 KB |
Output isn't correct |
20 |
Correct |
484 ms |
8144 KB |
Output is correct |