#include <iostream>
#include <algorithm>
using namespace std;
const int nmax = 1e6 + 7;
long long n, m, d;
struct nr
{
long long x;
int poz;
}v[nmax];
bool cmp(nr a, nr b)
{
return a.x < b.x;
}
int solve(long long m)
{
int 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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
40 ms |
2408 KB |
Output isn't correct |
2 |
Incorrect |
39 ms |
2452 KB |
Output isn't correct |
3 |
Incorrect |
39 ms |
2380 KB |
Output isn't correct |
4 |
Incorrect |
39 ms |
2380 KB |
Output isn't correct |
5 |
Incorrect |
39 ms |
2396 KB |
Output isn't correct |
6 |
Incorrect |
45 ms |
2372 KB |
Output isn't correct |
7 |
Incorrect |
39 ms |
2420 KB |
Output isn't correct |
8 |
Incorrect |
40 ms |
2464 KB |
Output isn't correct |
9 |
Correct |
149 ms |
2528 KB |
Output is correct |
10 |
Correct |
140 ms |
2636 KB |
Output is correct |
11 |
Correct |
37 ms |
2380 KB |
Output is correct |
12 |
Correct |
90 ms |
4660 KB |
Output is correct |
13 |
Correct |
106 ms |
6912 KB |
Output is correct |
14 |
Correct |
181 ms |
9160 KB |
Output is correct |
15 |
Incorrect |
180 ms |
11596 KB |
Output isn't correct |
16 |
Correct |
248 ms |
13804 KB |
Output is correct |
17 |
Correct |
290 ms |
15960 KB |
Output is correct |
18 |
Correct |
299 ms |
18320 KB |
Output is correct |
19 |
Correct |
447 ms |
20684 KB |
Output is correct |
20 |
Correct |
290 ms |
15980 KB |
Output is correct |