Cod sursa(job #1394183)
Utilizator | Data | 20 martie 2015 09:03:18 | |
---|---|---|---|
Problema | Loto | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 1.24 kb |
#include <iostream>
#include<fstream>
using namespace std;
int n,s,y,x,c,i,v[100000],p=1,aux;
int main()
{
ifstream f("loto.in");
ofstream g("loto.out");
f>>n>>s;
for(i=1;i<=n;i++)
f>>v[i];
i=1;
x=n;
if(6*n<s)
g<<"-1";
else if(6*n==s)
g<<n<<" "<<n<<" "<<n<<" "<<n<<" "<<n<<" "<<n;
else
{
while(s>0 || i<6)
{
if(s-x<0)
x--;
else
{
s=s-x;
v[i]=x;
i++;
}
}
for(y=1;y<=6;y++)
if(v[y]==0)
{
v[p]=v[p]-1;
v[y]=1;
p++;
}
for(i=1;i<=5;i++)
for(y=i+1;y<=6;y++)
if(v[i]>v[y])
{
aux=v[i];
v[i]=v[y];
v[y]=aux;
}
for(y=1;y<=6;y++)
g<<v[y]<< " ";
}
f.close();
g.close();
return 0;
}