#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,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 |
40 ms |
2232 KB |
Output is correct |
2 |
Correct |
38 ms |
2276 KB |
Output is correct |
3 |
Correct |
37 ms |
2200 KB |
Output is correct |
4 |
Correct |
37 ms |
2284 KB |
Output is correct |
5 |
Correct |
39 ms |
2308 KB |
Output is correct |
6 |
Correct |
53 ms |
2280 KB |
Output is correct |
7 |
Correct |
47 ms |
2316 KB |
Output is correct |
8 |
Correct |
54 ms |
2284 KB |
Output is correct |
9 |
Correct |
49 ms |
2420 KB |
Output is correct |
10 |
Correct |
48 ms |
2376 KB |
Output is correct |
11 |
Correct |
49 ms |
2228 KB |
Output is correct |
12 |
Incorrect |
34 ms |
1760 KB |
Output isn't correct |
13 |
Incorrect |
35 ms |
1804 KB |
Output isn't correct |
14 |
Incorrect |
38 ms |
1732 KB |
Output isn't correct |
15 |
Incorrect |
35 ms |
1840 KB |
Output isn't correct |
16 |
Incorrect |
39 ms |
1832 KB |
Output isn't correct |
17 |
Incorrect |
39 ms |
1724 KB |
Output isn't correct |
18 |
Incorrect |
36 ms |
1716 KB |
Output isn't correct |
19 |
Incorrect |
39 ms |
1832 KB |
Output isn't correct |
20 |
Incorrect |
39 ms |
1732 KB |
Output isn't correct |