Cod sursa(job #1891092)
Utilizator | Data | 23 februarie 2017 18:50:51 | |
---|---|---|---|
Problema | Ghiozdan | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 3.48 kb |
#include <fstream>
using namespace std;
/**
`-.`'.-'
`-. .-'.
`-. -./\.- .-'
-. /_|\ .-
`-. `/____\' .-'.
`-. -./.-""-.\.- '
`-. /< (()) >\ .-'
- .`/__`-..-'__\' .-
,...`-./___|____|___\.-'.,.
,-' ,` . . ', `-,
,-' ________________ `-,
,'/____|_____|_____\
/ /__|_____|_____|___\
/ /|_____|_____|_____|_\
' /____|_____|_____|_____\
.' /__|_____|_____|_____|___\
,' /|_____|_____|_____|_____|_\
,,---''--...___...--'''--.. /../____|_____|_____|_____|_____\ ..--```--...___...--``---,,
'../__|_____|_____|_____|_____|___\
\ ) '.:/|_____|_____|_____|_____|_____|_\ ( /
)\ / ) ,':./____|_____|_____|_____|_____|_____\ ( \ /(
/ / ( ( /:../__|_____|_____|_____|_____|_____|___\ ) ) \ \
| | \ \ /.../|_____|_____|_____|_____|_____|_____|_\ / / | |
.-.\ \ \ \ '..:/____|_____|_____|_____|_____|_____|_____\ / / / /.-.
(= )\ `._.' | \:./ _ _ ___ ____ ____ _ _ _ _ _ _ _ __\ | `._.' /( =)
\ (_) ) \/ \ ( (_) /
\ `----' """""""""""""""""""""""""""""""""""""""""""""" `----' /
\ ____\__ __/____ /
\ (=\ \ / /-) /
\_)_\ \ / /_(_/
\ \ / /
) ) _ _ ( (
( (,-' `-..__ __..-' `-,) )
\_.-'' ``-..____ ____..-'' ``-._/
`-._ ``--...____...--'' _.-'
`-.._ _..-'
`-..__ NOT MY IDEA - Edward __..-'
``-..____ ____..-''
``--...____...--''
*/
ifstream fin("ghiozdan.in");
ofstream fout("ghiozdan.out");
int fr[201],x,poz,k,i,j,nr,n,g,c[75001];
int main()
{
fin>>n>>g;
for (i=1; i<=n; i++)
{
fin>>x;
fr[x]++;
}
c[0]=1;
for (i=200; i>=1; i--) if (fr[i])
for (j=g; j>=0; j--) if (c[j])
for(k=1; k<=fr[i] and j+k*i<=g ; k++)
{
poz=j+k*i;
if (c[poz]) break ;
c[poz]=i;
}
for (i=g; c[i]==0; i--);
fout<<i<<" ";
for (j=i; j!=0; j-=c[j]) nr++;
fout<<nr<<'\n';
for (j=i; j!=0; j-=c[j]) fout<<c[j]<<'\n';
return 0;
}