#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 d,int n,int m){
int z,i,rasp,stg,j,poz;
i=stg=1;poz=0;
///printf("%d \n",v[2].a);
while(i<=n && stg && poz<m){///printf("a");
for(j=0;j<mij&& poz<m;j++){
//printf("%d ",poz);
if(v[poz].a>i){//printf("| %d %d |",v[poz].a,i);
break;
}else if(v[poz].a+d<i && poz<m){
//printf("{%d %d} ",v[poz].a+d,i);
stg=0;
break;
}else{
poz++;
}
}
i++;
}
//printf("mij: %d | i (<=n) : %d | poz (==m) : %d | stg(==1) : %d\n",mij,i,poz,stg);
if(i<=n && poz==m && stg==1)
return 1;
else
return 0;
}
int main()
{
int st,dr,mij,d,rasp,i,vf,j, stg,poz;
cin>>n>>d>>m;
for(i=0;i<m;i++){
cin>>v[i].a;
v[i].ind=i+1;
}
sort(v,v+m,cmp);
st=1;dr=m/d+1;rasp=mij=0;
while(st<dr){
mij=(st+dr)/2;
vf=verf(mij,d,n,m);
if(vf==1){
rasp=mij;
dr=mij-1;
}else{
st=mij+1;
}
}
cout<<rasp<<"\n";
mij=rasp;
i=stg=1;poz=0;
while(i<=n && stg ){///printf("a");
for(j=0;j<mij;j++){
if(v[poz].a>i)
break;
else{
printf("%d ",v[poz].ind);
poz++;
}
}
printf("0\n");
i++;
}
return 0;
}
Compilation message
jobs.cpp: In function 'bool verf(int, int, int, int)':
jobs.cpp:19:9: warning: unused variable 'z' [-Wunused-variable]
19 | int z,i,rasp,stg,j,poz;
| ^
jobs.cpp:19:13: warning: unused variable 'rasp' [-Wunused-variable]
19 | int z,i,rasp,stg,j,poz;
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
82 ms |
3404 KB |
Output isn't correct |
2 |
Incorrect |
83 ms |
3412 KB |
Output isn't correct |
3 |
Incorrect |
81 ms |
3416 KB |
Output isn't correct |
4 |
Incorrect |
82 ms |
3384 KB |
Output isn't correct |
5 |
Incorrect |
93 ms |
3468 KB |
Output isn't correct |
6 |
Incorrect |
83 ms |
3420 KB |
Output isn't correct |
7 |
Incorrect |
84 ms |
3420 KB |
Output isn't correct |
8 |
Incorrect |
82 ms |
3404 KB |
Output isn't correct |
9 |
Incorrect |
85 ms |
3624 KB |
Expected EOLN |
10 |
Incorrect |
86 ms |
3604 KB |
Expected EOLN |
11 |
Incorrect |
29 ms |
1664 KB |
Output isn't correct |
12 |
Incorrect |
59 ms |
3124 KB |
Output isn't correct |
13 |
Incorrect |
89 ms |
4552 KB |
Output isn't correct |
14 |
Incorrect |
134 ms |
6200 KB |
Output isn't correct |
15 |
Incorrect |
150 ms |
7572 KB |
Output isn't correct |
16 |
Incorrect |
204 ms |
9036 KB |
Expected EOLN |
17 |
Incorrect |
238 ms |
10572 KB |
Output isn't correct |
18 |
Incorrect |
250 ms |
12364 KB |
Expected EOLN |
19 |
Incorrect |
281 ms |
13968 KB |
Output isn't correct |
20 |
Incorrect |
237 ms |
10572 KB |
Output isn't correct |