Pagini recente » Cod sursa (job #2032373) | Cod sursa (job #1913406) | Cod sursa (job #1012496) | Cod sursa (job #756457) | Cod sursa (job #785290)
Cod sursa(job #785290)
#include <cstdio>
using namespace std;
const int Gmax = 75010;
const int Omax = 210;
const int O = 200;
int D[Gmax][Omax];
int N,G;
int main()
{
freopen("ghiozdan.in","r",stdin);
freopen("ghiozdan.out","w",stdout);
scanf("%d %d\n",&N,&G);
for (int i=1,X;i<=N;++i)
{
scanf("%d\n",&X);
++D[0][X];
++D[0][0];
}
++D[0][0];
for (int i=0;i<=G;++i)
for (int j=O;j;--j)
if ( D[i][j] && i+j<=G && D[i+j][0]==0 )
{
for (int k=1;k<=O;++k)
D[i+j][k]=D[i][k];
--D[i+j][j];
D[i+j][0]=D[i][0]-1;
}
int Sol,Co;for (Sol=G;D[Sol][0]==0;--Sol);
Co=D[0][0]-D[Sol][0];
printf("%d %d\n",Sol,Co);
for (int j=1;j<=O;++j)
for ( ; D[0][j]-D[Sol][j] ; ++D[Sol][j] )
printf("%d\n",j);
fclose(stdin);
fclose(stdout);
}