#include <bits/stdc++.h>
using namespace std;
int n,d,m;
int a[100001];
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");
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
2076 KB |
Output is correct |
2 |
Correct |
36 ms |
2104 KB |
Output is correct |
3 |
Correct |
36 ms |
2204 KB |
Output is correct |
4 |
Correct |
36 ms |
2112 KB |
Output is correct |
5 |
Correct |
37 ms |
2160 KB |
Output is correct |
6 |
Correct |
37 ms |
2104 KB |
Output is correct |
7 |
Correct |
37 ms |
2148 KB |
Output is correct |
8 |
Correct |
36 ms |
2112 KB |
Output is correct |
9 |
Correct |
49 ms |
2360 KB |
Output is correct |
10 |
Correct |
49 ms |
2360 KB |
Output is correct |
11 |
Correct |
48 ms |
2112 KB |
Output is correct |
12 |
Incorrect |
34 ms |
1676 KB |
Output isn't correct |
13 |
Incorrect |
37 ms |
1664 KB |
Output isn't correct |
14 |
Incorrect |
37 ms |
1684 KB |
Output isn't correct |
15 |
Incorrect |
33 ms |
1604 KB |
Output isn't correct |
16 |
Incorrect |
38 ms |
1604 KB |
Output isn't correct |
17 |
Incorrect |
41 ms |
1688 KB |
Output isn't correct |
18 |
Incorrect |
35 ms |
1732 KB |
Output isn't correct |
19 |
Incorrect |
40 ms |
1748 KB |
Output isn't correct |
20 |
Incorrect |
38 ms |
1596 KB |
Output isn't correct |