#B3780. Table Arrangement in Classroom
Table Arrangement in Classroom
Table Arrangement in Classroom
In this problem, zyl is asked by his math teacher to arrange tables in a classroom. The teacher requires that the total number of tables equals the total number of students. However, zyl does not know how many students there are in total.
There are \(n\) cabinets located at the back of the classroom, numbered from \(1\) to \(n\). The \(i\)-th cabinet consists of \(a_i\times b_i\) grid cells, and each cell is shared by exactly \(c_i\) students. That is, the \(i\)-th cabinet is used by \(a_i\times b_i\times c_i\) students.
Thus, the total number of students is computed as:
\[ T = \sum_{i=1}^{n} a_i \times b_i \times c_i \]Once the total number of tables (which is equal to \(T\)) is determined, they need to be arranged in \(m\) columns. The tables are arranged row by row, filling each row with \(m\) tables. If the total number of tables is not a multiple of \(m\), the remaining tables form an additional (incomplete) row at the end.
Your task is to calculate two values:
- The total number of rows after placing all tables.
- The number of tables in the last row.
Note: If all rows are completely filled (i.e. the total number of tables is a multiple of \(m\)), then the last row is considered to have \(m\) tables.
inputFormat
The first line of input contains two integers \(n\) and \(m\), where \(n\) is the number of cabinets and \(m\) is the number of columns to arrange the tables.
Each of the following \(n\) lines contains three positive integers \(a_i\), \(b_i\), and \(c_i\) representing that the \(i\)-th cabinet has \(a_i\times b_i\) cells and each cell is used by \(c_i\) students.
outputFormat
Output two numbers separated by a space:
- The total number of rows after arranging the tables.
- The number of tables in the last row.
sample
3 5
2 3 1
3 2 1
1 2 1
3 4