Mai intai trebuie sa te autentifici.
Cod sursa(job #2020091)
Utilizator | Data | 9 septembrie 2017 13:45:30 | |
---|---|---|---|
Problema | Loto | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.79 kb |
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
freopen("loto.in","r",stdin);
freopen("loto.out","w",stdout);
int n , s , i , nr;
scanf("%d%d",&n,&s);
vector<int>v;
for(i=0;i<n;i++)
{
scanf("%d",&nr);
v.push_back(nr);
}
sort(v.begin(),v.end());
vector<int>::iterator it ,it1;
it=v.end()-1;
it1=v.begin();
if((*it)*6<s)
{
printf("-1");
return 0;
}
if((*it1)*6>s)
{
printf("-1");
return 0;
}
i=6;
while(i)
{
nr=s/i;
if(s%i!=0)nr++;
it=lower_bound(v.begin(),v.end(),nr);
s-=nr;
printf("%d ",*it);
i--;
}
printf("\n");
return 0;
}