#include <bits/stdc++.h>
using namespace std;
long long n, d, m ;
struct neveu
{
int a, b ;
} v [ 1000005 ];
bool check(long long caz )
{
int ziua = 1 ;
for ( int i = 1; i <= m ; i += caz, ziua ++ )
{
if ( v[ i ].a < ziua )
return false ;
}
return true ;
}
bool compare ( neveu x, neveu y)
{
return ( x. a < y . a );
}
int main()
{
cin >> n >> d >> m ;
for ( int i = 1; i <= m ; i ++ )
{
cin >> v[ i ].a ;
v [ i ].a += d ;
v [ i] . b = i ;
}
sort ( v + 1, v + m + 1, compare) ;
long long poz = 1e9 ;
int st = m / n , dr = m ;
while ( st <= dr )
{
long long mij = ( st + dr ) / 2 ;
if ( check ( mij ) == true )
{
poz = mij ;
dr = mij - 1;
}
else
st = mij + 1;
}
cout << poz << '\n' ;
long long masini = poz ;
long long ziua = 1 ;
for ( int i = 1; i <= m ; i ++ )
{
cout << v [ i ].b << " ";
masini -- ;
if ( masini == 0 )
{
cout << 0 << '\n';
masini = poz ;
ziua ++ ;
}
}
while ( ziua <= n )
{
cout << 0 << '\n';
ziua ++ ;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
1748 KB |
Output isn't correct |
2 |
Incorrect |
22 ms |
1704 KB |
Output isn't correct |
3 |
Incorrect |
24 ms |
1760 KB |
Output isn't correct |
4 |
Incorrect |
22 ms |
1808 KB |
Output isn't correct |
5 |
Incorrect |
22 ms |
1716 KB |
Output isn't correct |
6 |
Incorrect |
26 ms |
1772 KB |
Output isn't correct |
7 |
Incorrect |
22 ms |
1748 KB |
Output isn't correct |
8 |
Incorrect |
24 ms |
1704 KB |
Output isn't correct |
9 |
Correct |
30 ms |
2100 KB |
Output is correct |
10 |
Correct |
29 ms |
2008 KB |
Output is correct |
11 |
Correct |
35 ms |
1592 KB |
Output is correct |
12 |
Correct |
58 ms |
3188 KB |
Output is correct |
13 |
Correct |
82 ms |
4636 KB |
Output is correct |
14 |
Correct |
132 ms |
6456 KB |
Output is correct |
15 |
Incorrect |
134 ms |
7568 KB |
Output isn't correct |
16 |
Correct |
195 ms |
9288 KB |
Output is correct |
17 |
Correct |
222 ms |
10736 KB |
Output is correct |
18 |
Correct |
215 ms |
12156 KB |
Output is correct |
19 |
Correct |
270 ms |
14052 KB |
Output is correct |
20 |
Correct |
217 ms |
10760 KB |
Output is correct |