#include <iostream>
#include <algorithm>
using namespace std;
const int nmax = 1e6 + 7;
long long n, m, d;
struct nr
{
long long x;
long long poz;
}v[nmax];
bool cmp(nr a, nr b)
{
return a.x < b.x;
}
long long solve(long long m)
{
long long ok = 1, i;
for(i=1; i<=n; i++)
if(i > (v[i].x + d) * m)
ok = 0;
return ok;
}
int main()
{
long long i,st,dr,ans = -1;
cin >> m >> d >> n;
for(i=1; i<=n; i++)
{
cin >> v[i].x;
v[i].poz = i;
}
sort(v+1,v+1+n,cmp);
st = 0;
dr = n;
while(st <= dr)
{
long long mij = (st + dr) / 2;
if(solve(mij) == 1)
{
ans = mij;
dr = mij - 1;
}
else
st = mij + 1;
}
cout << ans << endl;
for(i=1;i<=n;i++)
{
cout << v[i].poz << " ";
if(i % ans == 0)
cout << 0 <<endl;
}
i = i / ans + 1;
while(i <= m)
{
cout << 0 << endl;
i++;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
41 ms |
2388 KB |
Output isn't correct |
2 |
Incorrect |
38 ms |
2480 KB |
Output isn't correct |
3 |
Incorrect |
39 ms |
2464 KB |
Output isn't correct |
4 |
Incorrect |
38 ms |
2388 KB |
Output isn't correct |
5 |
Incorrect |
38 ms |
2388 KB |
Output isn't correct |
6 |
Incorrect |
38 ms |
2396 KB |
Output isn't correct |
7 |
Incorrect |
39 ms |
2464 KB |
Output isn't correct |
8 |
Incorrect |
41 ms |
2464 KB |
Output isn't correct |
9 |
Correct |
138 ms |
2624 KB |
Output is correct |
10 |
Correct |
139 ms |
2636 KB |
Output is correct |
11 |
Correct |
37 ms |
2412 KB |
Output is correct |
12 |
Correct |
75 ms |
4700 KB |
Output is correct |
13 |
Correct |
104 ms |
6932 KB |
Output is correct |
14 |
Correct |
169 ms |
9216 KB |
Output is correct |
15 |
Incorrect |
184 ms |
11420 KB |
Output isn't correct |
16 |
Correct |
249 ms |
13728 KB |
Output is correct |
17 |
Correct |
298 ms |
16004 KB |
Output is correct |
18 |
Correct |
294 ms |
18248 KB |
Output is correct |
19 |
Correct |
434 ms |
20836 KB |
Output is correct |
20 |
Correct |
299 ms |
16004 KB |
Output is correct |