#include <bits/stdc++.h>
using namespace std;
int n,d,m;
int a[10001];
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 |
Incorrect |
3 ms |
460 KB |
Output isn't correct |
2 |
Incorrect |
3 ms |
460 KB |
Output isn't correct |
3 |
Incorrect |
3 ms |
460 KB |
Output isn't correct |
4 |
Incorrect |
3 ms |
460 KB |
Output isn't correct |
5 |
Incorrect |
3 ms |
460 KB |
Output isn't correct |
6 |
Incorrect |
3 ms |
556 KB |
Output isn't correct |
7 |
Incorrect |
3 ms |
460 KB |
Output isn't correct |
8 |
Incorrect |
3 ms |
460 KB |
Output isn't correct |
9 |
Incorrect |
9 ms |
648 KB |
Output isn't correct |
10 |
Incorrect |
8 ms |
716 KB |
Output isn't correct |
11 |
Incorrect |
4 ms |
460 KB |
Output isn't correct |
12 |
Incorrect |
4 ms |
460 KB |
Output isn't correct |
13 |
Incorrect |
4 ms |
460 KB |
Output isn't correct |
14 |
Incorrect |
6 ms |
552 KB |
Output isn't correct |
15 |
Incorrect |
4 ms |
460 KB |
Output isn't correct |
16 |
Incorrect |
5 ms |
460 KB |
Output isn't correct |
17 |
Incorrect |
6 ms |
588 KB |
Output isn't correct |
18 |
Incorrect |
4 ms |
464 KB |
Output isn't correct |
19 |
Incorrect |
9 ms |
776 KB |
Output isn't correct |
20 |
Incorrect |
6 ms |
588 KB |
Output isn't correct |