#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n,d,m;
cin>>n>>d>>m;
pair<long long,long long> niza[m];
for(long long i=0; i<m; i++)
{
cin>>niza[i].first;
niza[i].second=i+1;
}
sort(niza,niza+m);
long long b=0,e=m+1;
long long res=0;
while(b<=e)
{
long long mid=(b+e)/2;
long long cnt=0;
long long day=1;
long long og=0;
bool flag=true;
for(long long i=0; i<m; i++)
{
cnt++;
if(cnt>mid || (niza[i].first>day && niza[i].first-niza[og].first>d))
{
cnt=1;
og=i;
day++;
}
if(day-niza[i].first>d || day>n)
{
flag=false;
break;
}
}
if(flag)
{
res=mid;
e=mid-1;
}
else b=mid+1;
}
cout<<res<<endl;
long long cnt=0;
long long day=1;
long long og=0;
vector<long long> ress[n+1];
for(long long i=0; i<m; i++)
{
cnt++;
if(cnt>res || (niza[i].first>day && niza[i].first-niza[og].first>d))
{
cnt=1;
og=i;
day++;
}
ress[day].push_back(niza[i].second);
}
for(long long i=1; i<=n; i++)
{
for(auto x:ress[i])cout<<x<<" ";
cout<<0<<endl;
}
return 0;
}
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
3932 KB |
Output isn't correct |
2 |
Incorrect |
21 ms |
4068 KB |
Output isn't correct |
3 |
Incorrect |
25 ms |
3932 KB |
Output isn't correct |
4 |
Incorrect |
32 ms |
4092 KB |
Output isn't correct |
5 |
Incorrect |
21 ms |
3932 KB |
Output isn't correct |
6 |
Incorrect |
21 ms |
3932 KB |
Output isn't correct |
7 |
Incorrect |
22 ms |
4256 KB |
Output isn't correct |
8 |
Incorrect |
21 ms |
4188 KB |
Output isn't correct |
9 |
Correct |
110 ms |
6228 KB |
Output is correct |
10 |
Correct |
132 ms |
6088 KB |
Output is correct |
11 |
Correct |
21 ms |
3920 KB |
Output is correct |
12 |
Correct |
41 ms |
7660 KB |
Output is correct |
13 |
Correct |
62 ms |
12112 KB |
Output is correct |
14 |
Correct |
98 ms |
16468 KB |
Output is correct |
15 |
Incorrect |
93 ms |
17596 KB |
Output isn't correct |
16 |
Correct |
129 ms |
22100 KB |
Output is correct |
17 |
Correct |
157 ms |
29776 KB |
Output is correct |
18 |
Correct |
166 ms |
29728 KB |
Output is correct |
19 |
Runtime error |
296 ms |
34640 KB |
Memory limit exceeded |
20 |
Correct |
155 ms |
29588 KB |
Output is correct |