Cod sursa(job #1222010)

Utilizator g3ppyStoian Vlad g3ppy Data 21 august 2014 21:45:47
Problema Loto Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.46 kb
#include <algorithm>
#include <vector>
#include <stdio.h>

#define NMAX 101
#define llong long long

using namespace std;

struct three {
    three(int zero, int one, int two) {
        this->zero = zero;
        this->one = one;
        this->two = two;
        this->sum = zero + one + two;
    }

    llong sum;
    int zero, one, two;
};

int numbers[NMAX];

vector<three> threes;

bool compare_threes(three t1, three t2) {
    return t1.sum < t2.sum;
}

int main() {
    freopen("loto.in", "rt", stdin);
    freopen("loto.out", "wt", stdout);

    llong n, s;
    scanf("%lld %lld\n", &n, &s);


    for (int i = 0; i < n; i++) {
        scanf("%d", &numbers[i]);
    }

    threes.reserve(n * n * n);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                three element(numbers[i], numbers[j], numbers[k]);
                threes.push_back(element);
            }
        }
    }

    sort(threes.begin(), threes.end(), compare_threes);

    return 0;


//    for (it = threes.rbegin(); it != threes.rend(); it++) {
//        llong first_sum = it->first;
//        llong second_sum = s - first_sum;

//        sit = threes.find(second_sum);

//        if (sit != threes.end()) {
//           printf("%d %d %d %d %d %d\n", it->second.zero, it->second.one, it->second.two, sit->second.zero, sit->second.one, sit->second.two);
//           return 0;
//        }
//    }


    printf("%d\n", -1);

    return 0;
}