Untitled

                Never    
C++
       
// ConsoleApplication5.cpp: определяет точку входа для консольного приложения.
//

#include "stdafx.h"
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

struct comp {
	int num;
	float price;
};

vector<int> cur_ans;
vector<vector<int> > ans;
vector<vector<comp> > list(5);


void dfs(int cur_t, int cur_c, float &cur_price, int min_price, int max_price) {
	
	if (cur_t == -1) {
		for (int i = 0; i < list[cur_t + 1].size(); ++i)
			dfs(cur_t + 1, i, cur_price, min_price, max_price);
		return;
	}
	
	cur_ans.resize(cur_ans.size() + 1);
	cur_ans[cur_ans.size() - 1] = cur_c;

	if (cur_t < list.size())
		cur_price += list[cur_t][cur_c].price;

	if (cur_t == list.size() - 1 && min_price <= cur_price && cur_price <= max_price) {
		ans.resize(ans.size() + 1);
		for (int i = 0; i < cur_ans.size(); ++i) {
			
			//ans[ans.size() - 1].resize(ans[ans.size() - 1].size() + 1);
			ans[ans.size() - 1].push_back(cur_ans[i]);
			//cout << cur_ans[i] << ' ';
		}
		//cout << " - " << cur_price << endl;
	}

	if (cur_t < list.size()) {
		for (int i = 0; i < list[cur_t].size(); ++i)
			dfs(cur_t + 1, i, cur_price, min_price, max_price);
		cur_price -= list[cur_t][cur_c].price;
	}
	cur_ans.resize(cur_ans.size() - 1);
}

int main()
{
	comp tmp;
	for (int i = 0; i < list.size(); ++i) {
		for (int j = 0; j < 2; ++j) {
			cin >> tmp.num >> tmp.price;
			list[i].push_back(tmp);
		}
	}

	float min_price = 24, max_price = 25;
	
	float cur_price = 0;
	dfs(-1, 0, cur_price, min_price, max_price);

	for (int i = 0; i < ans.size(); ++i) {
		int cur_price = 0;
		for (int j = 0; j < ans[i].size(); ++j) {
			cout << list[j][ans[i][j]].num << ' ';
			cur_price += list[j][ans[i][j]].price;
		}
		cout << "- " << cur_price << endl;
	}

	system("pause>>void");
    return 0;
}

/*
	1 1
	2 5
	1 9
	2 7
	1 3
	2 2
	1 5
	2 10
	1 4
	2 5
*/