#include <iostream>
#include <algorithm>
using namespace std;
struct vc{
int a,ind;
}v[1000000];
bool cmp(vc a,vc b){
if(a.a<b.a)
return 1;
else
return 0;
}
int n,m;
bool verf(int mij){
int z,i,dr,st,mmij,rasp;
z=mij-1;i=1;
while(z<m-1 && i<=n){///printf("a");
dr=z;rasp=dr;
st=z-mij+1;
while(st<dr){
mmij=(st+dr)/2;
if(v[mmij].a>i)
dr=mmij-1;
else{
rasp=mmij;
st=mmij-1;
}
}
z=rasp;
if(i>v[z].a)
break;
i++;
z=min(z+mij,m-1);
}
if(z<m-1 && i<=n)
return 0;
else
return 1;
}
int main()
{
int st,dr,mij,d,rasp,i,vf,poz,j;
cin>>n>>d>>m;
for(i=0;i<m;i++){
cin>>v[i].a;
v[i].ind=i+1;
v[i].a+=d;
}
sort(v,v+m,cmp);
st=1;dr=1000000;rasp=mij=0;
while(st<=dr){
mij=(st+dr)/2;
vf=verf(mij);
if(vf==1){
rasp=mij;
dr=mij-1;
}else{
st=mij+1;
}
}
cout<<rasp<<"\n";
poz=0;
for(i=0;i<n;i++){
for(j=0;j<rasp && poz<m;j++){
cout<<v[poz].ind<<" ";
poz++;
}
cout<<"0\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1070 ms |
1236 KB |
Time limit exceeded |
2 |
Execution timed out |
1078 ms |
1236 KB |
Time limit exceeded |
3 |
Execution timed out |
1087 ms |
1236 KB |
Time limit exceeded |
4 |
Execution timed out |
1083 ms |
1236 KB |
Time limit exceeded |
5 |
Execution timed out |
1075 ms |
1240 KB |
Time limit exceeded |
6 |
Execution timed out |
1081 ms |
1240 KB |
Time limit exceeded |
7 |
Execution timed out |
1090 ms |
1236 KB |
Time limit exceeded |
8 |
Execution timed out |
1083 ms |
1236 KB |
Time limit exceeded |
9 |
Execution timed out |
1080 ms |
1108 KB |
Time limit exceeded |
10 |
Execution timed out |
1076 ms |
1108 KB |
Time limit exceeded |
11 |
Execution timed out |
1073 ms |
1336 KB |
Time limit exceeded |
12 |
Execution timed out |
1070 ms |
2380 KB |
Time limit exceeded |
13 |
Execution timed out |
1070 ms |
3528 KB |
Time limit exceeded |
14 |
Execution timed out |
1075 ms |
4964 KB |
Time limit exceeded |
15 |
Execution timed out |
1077 ms |
5856 KB |
Time limit exceeded |
16 |
Execution timed out |
1085 ms |
7372 KB |
Time limit exceeded |
17 |
Execution timed out |
1041 ms |
8692 KB |
Time limit exceeded |
18 |
Execution timed out |
1086 ms |
9244 KB |
Time limit exceeded |
19 |
Execution timed out |
1077 ms |
10444 KB |
Time limit exceeded |
20 |
Execution timed out |
1072 ms |
8696 KB |
Time limit exceeded |