Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class List {
- public:
- void append(List list) {}
- int getTotalSize() { return 0; }
- bool operator>(const List) { return true; }
- };
- int main() {
- int b = 10;
- List list;
- unsigned long long one = 1; // zmienne uzywane do kombinacji
- unsigned long long null = (unsigned long long int) n; // elementow do wziecia
- unsigned long long onenull = one << null;
- List *temp;
- auto *maxList = new List; // lista z najwieksza wartoscia
- for (unsigned long long p = 0; p < onenull; p++) {
- temp = new List; // nowa tymczasowa lista
- for (unsigned long long i = 0; i < null; i++)
- if (p & one << i) // sprawdza czy dodac te krawedz
- temp->append(list)[i]);
- if (temp->getTotalSize() <= b and *temp > *maxList) { // jesli calkowity rozmiar mniejszy od pojemnosci plecaka
- *maxList = *temp; // i wartosc wieksza, to wyczysc i zamien
- }
- delete temp;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement