Submission

Status:

[PPPP][PPPP][PPPP][PPPP][PPPP][PPPP][PPPP][PPPP]

Subtask/Task Score:

{13/13}{13/13}{13/13}{13/13}{13/13}{13/13}{13/13}{13/13}

Score: 100

User: nb21st

Problemset: ขนมปัง

Language: cpp

Time: 0.002 second

Submitted On: 2025-10-17 16:23:28

#include <bits/stdc++.h>
using namespace std;


int main(void)
{
	int a_size[1001];
	int w, h, n, m;
	cin >> w >> h >> n >> m;


	for (int i = 0; i <= n; ++i)
	{
		static int n_last;
		int in;

		if (i == n)
		{
			in = w;
		}
		else
		{
			cin >> in;
		}

		a_size[i] = in - n_last;
		n_last = in;
	}


	int first_max = 0, second_max = 0;

	for (int i = 0; i <= m; ++i)
	{
		static int m_last;
		int in;

		if (i == m)
		{
			in = h;
		}
		else
		{
			cin >> in;
		}

		int b_size = in - m_last;

		for (int j = 0; j <= n; ++j)
		{
			int c_size = a_size[j] * b_size;

			if (c_size > first_max)
			{
				second_max = first_max;
				first_max = c_size;
			}
			else if (c_size > second_max)
			{
				second_max = c_size;
			}
		}

		m_last = in;
	}

	cout << first_max << ' ' << second_max << endl;

	return 0;
}