Cod sursa(job #323558)

Utilizator doru.nituNitu Doru Constantin doru.nitu Data 12 iunie 2009 16:47:29
Problema Loto Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.48 kb
#include<stdio.h>
#include<algorithm>
using namespace std;
long long a[100];
long long s;
long long sor[1000001],i,j,k,n,nr,x,y;

struct nod
{ long long x,y,z,s;
} b[1000001];

bool fcomp(long long x,long long  y)
{ return b[x].s<b[y].s;
} 

int main()
{ freopen("loto.in","r",stdin);
  freopen("loto.out","w",stdout);
  scanf("%d %lld",&n,&s);
  for(i=1;i<=n;i++) scanf("%lld",&a[i]);
  
  for(i=1;i<=n;i++)
      for(j=i;j<=n;j++)
          for(k=j;k<=n;k++)
                 { b[++nr].x=a[i];
                   b[nr].y=a[j];
                   b[nr].z=a[k];
                   b[nr].s=a[i]+a[j]+a[k];
                   sor[nr]=nr;
                 }
  sort(sor+1,sor+nr+1,fcomp);
//  y=nr;
//  x=1;
//  
//  while(x<=y)  
//         if(b[sor[x]].s+b[sor[y-1]].s>=s)  
//             --y;  
//         else  
//             if(b[sor[x]].s+b[sor[y]].s==s)  
//             {  
//                 printf("%lld ",b[sor[x]].x);
//                 printf("%lld ",b[sor[x]].y);
//                 printf("%lld ",b[sor[x]].z);
//                 printf("%lld ",b[sor[y]].x);
//                 printf("%lld ",b[sor[y]].y);
//                 printf("%lld\n",b[sor[y]].z);
//                 fclose(stdin);
//                 fclose(stdout);
//   
//.                return 0;  
//             }  
//   
//             else  
//   .              ++x;  

  printf("-1\n");
  fclose(stdin);
  fclose(stdout);
  return 0;
}