ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Сборники > Data Structures > задача:


50828 - Arranging Time Table

Гость
• Вопросы к жюри (1)

Задачи сборника

• 50997 - Dynamic Knights
• 50490 - Across the River
• 50816 - Largest Sum Path
• 50857 - Nine-Stones Game
• 50837 - Sum is equal to K
• 50772 - The Path of a Node
• 50936 - Saving the Soldiers
• 50447 - Swimming Contest - 2
• 50828 - Arranging Time Table
• 50794 - Writing Files Into HDD
• 50929 - Present from your uncles
• 50863 - Total Access Cost of a BST
• 50979 - Minimum access cost for BST
• 51000 - Book Index
• 51076 - Key person
• 51062 - Fish Pond II
• 51067 - Jumping frog

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Arranging Time Table

You have started working in North West Tirana high school. And, you have to arrange the time tables. There are classrooms with different sizes and several different student classes with different number of students. A student class may be assigned to a classroom, if the number of students in the class is less than or equal to the classroom capacity. For example, if there are 25 students in a class, it can be assigned to classroom with the capacity 27, but it can not be assigned to a classroom with the capacity 24.

Question: Write a program that is going to get information for n classrooms and k student classes. And then, it will show the possible placements.

Input specification
In the first line, you will be given two integers: The number of classrooms(n) and the number of student classes(k), where 0 ≤ k ≤ n ≤ 15. In the following line, you will be given n integers: the capacities of n classrooms. And in the following line, you will be given k integers: number of students in k classes.

Output specification:
In the first line, show total number of possible classroom arrangements (nRes). Then in the following nRes lines, show nr of students and classroom capacity pairs such that all student classes are assigned to classrooms where every pair is followed by a semicolon. If there is no possible placement, you print 0.
Note: There is no result (nRes) greater than 5,000.

Sample Input I
4 3
24 50 30 55
50 30 25
Sample Output I
4
50 50; 30 30; 25 55;
50 50; 25 30; 30 55;
30 50; 25 30; 50 55;
25 50; 30 30; 50 55;

Explanation: There are 4 possible arrangements.

  1. Class with 52 students can be assigned to classroom with the capacity 55
  2. Class with 25 students can be assigned to classroom with the capacity 50
  3. Class with 30 students can be assigned to classroom with the capacity 30
And, there are 3 other class to classroom arrangements.



Для отправки решений необходимо выполнить вход.

www.contester.ru