#include <bits/stdc++.h>
using namespace std;
int n,d,m;
int a[100006];
vector< pair<int,int> >par;
bool works(int x)
{
int curr=0;
for(int day=0;day<n;day++)
{
for(int j=0;j<x;j++)
{
if(curr<m && par[curr].first<=day+1 && par[curr].first>=day+1-d)
{
curr++;
}else
{
break;
}
}
}
if(curr==m)
{
return true;
}else
{
return false;
}
}
int main()
{
cin>>n>>d>>m;
for(int i=0;i<m;i++)
{
cin>>a[i];
par.push_back(make_pair(a[i],i+1));
}
sort(par.begin(),par.end());
int low=0,high=m-1,mid,ans=-1;
while(low<=high)
{
mid=(low+high)/2;
if(works(mid)==true)
{
ans=mid;
high=mid-1;
}else
{
low=mid+1;
}
}
cout<<ans<<endl;
int cur = 0;
for(int day=0;day<n;day++) {
for(int i=0;i<ans;i++) {
if(cur<m && par[cur].first<=day+1 && par[cur].first+d>=day+1) {
printf("%d ",par[cur].second);
cur++;
}
else break;
}
printf("0\n");
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
2100 KB |
Output is correct |
2 |
Correct |
38 ms |
2228 KB |
Output is correct |
3 |
Correct |
36 ms |
2168 KB |
Output is correct |
4 |
Correct |
40 ms |
2120 KB |
Output is correct |
5 |
Correct |
36 ms |
2124 KB |
Output is correct |
6 |
Correct |
36 ms |
2164 KB |
Output is correct |
7 |
Correct |
37 ms |
2112 KB |
Output is correct |
8 |
Correct |
36 ms |
2116 KB |
Output is correct |
9 |
Correct |
49 ms |
2380 KB |
Output is correct |
10 |
Correct |
49 ms |
2348 KB |
Output is correct |
11 |
Correct |
46 ms |
2112 KB |
Output is correct |
12 |
Incorrect |
34 ms |
1720 KB |
Output isn't correct |
13 |
Incorrect |
34 ms |
1688 KB |
Output isn't correct |
14 |
Incorrect |
38 ms |
1692 KB |
Output isn't correct |
15 |
Incorrect |
33 ms |
1604 KB |
Output isn't correct |
16 |
Incorrect |
37 ms |
1604 KB |
Output isn't correct |
17 |
Incorrect |
39 ms |
1620 KB |
Output isn't correct |
18 |
Incorrect |
37 ms |
1732 KB |
Output isn't correct |
19 |
Incorrect |
39 ms |
1732 KB |
Output isn't correct |
20 |
Incorrect |
41 ms |
1704 KB |
Output isn't correct |