/****************************************************************************** Online…
- User
/******************************************************************************
codeOnline C++ Compiler. Code, Compile, Run and Debug C++ program online.Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include
using namespace std;
int price(int row, int column, int **cuts, int **memory) { if (memory[row][column] != -1) { return memory[row][column]; } return cuts[row][column]; }
int row_cutter(int rows, int columns, int **cuts, int **memory) { int max_row_cut = 0;
codeif (memory[rows][columns] != -1) { return memory[rows][columns]; } for (int k = 1; k <= rows / 2; k++) { max_row_cut = max(max_row_cut, price(k, columns, cuts, memory) + price(rows - k, columns, cuts, memory)); } return max_row_cut;}
int column_cutter(int rows, int columns, int **cuts, int **memory) { int max_col_cut = 0;
codeif (memory[rows][columns] != -1) { return memory[rows][columns]; } for (int k = 1; k <= rows / 2; k++) { max_col_cut = std::max(max_col_cut, price(rows, k, cuts, memory) + price(rows, columns - k, cuts, memory)); } return max_col_cut;}
int plate_cutter(int rows, int columns, int cuts) { // Create memory for the program to run int mem_size = max(rows+1, columns+1); int memory = new int*[mem_size + 1]; for (int i = 0; i < mem_size; i++) { memory[i] = new int[mem_size + 1]; } for (int i = 0; i < mem_size; i++) { for (int j = 0; j < mem_size; j++) { memory[i][j] = -1; } }
code - Assistant
- User
give me the solved code then.
- Assistant