Cod sursa(job #2020088)

Utilizator MoldovanMoldovan Moldovan Data 9 septembrie 2017 13:43:35
Problema Loto Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 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;
    if((*it)*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 ",nr);
        i--;
    }
    printf("\n");
    return 0;
}