#include <bits/stdc++.h>
using namespace std;
int N,M,D;
int s[1000001];
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]);
if(s[i]+D<j)return false;
}
return true;
}
int main(){
cin>>N>>D>>M;
for(int i=0;i<M;i++)cin>>s[i];
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;
for(int i=0;i<N;i++){
for(int z=i*(x+1);z<M&&z<(i+1)*(x+1);z++)cout<<z+1<<" ";
cout<<0<<endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
79 ms |
1400 KB |
Output is correct |
2 |
Correct |
78 ms |
1400 KB |
Output is correct |
3 |
Correct |
79 ms |
1356 KB |
Output is correct |
4 |
Correct |
79 ms |
1400 KB |
Output is correct |
5 |
Correct |
78 ms |
1276 KB |
Output is correct |
6 |
Correct |
79 ms |
1272 KB |
Output is correct |
7 |
Correct |
79 ms |
1272 KB |
Output is correct |
8 |
Correct |
79 ms |
1400 KB |
Output is correct |
9 |
Partially correct |
320 ms |
1600 KB |
Partially correct |
10 |
Partially correct |
318 ms |
1524 KB |
Partially correct |
11 |
Partially correct |
64 ms |
1272 KB |
Partially correct |
12 |
Partially correct |
126 ms |
2424 KB |
Partially correct |
13 |
Partially correct |
186 ms |
3704 KB |
Partially correct |
14 |
Partially correct |
312 ms |
4684 KB |
Partially correct |
15 |
Incorrect |
306 ms |
5752 KB |
Output isn't correct |
16 |
Partially correct |
443 ms |
6800 KB |
Partially correct |
17 |
Partially correct |
522 ms |
8136 KB |
Partially correct |
18 |
Partially correct |
528 ms |
9080 KB |
Partially correct |
19 |
Incorrect |
824 ms |
10360 KB |
Output isn't correct |
20 |
Partially correct |
516 ms |
7980 KB |
Partially correct |