Submission

Status:

[-SSS][PP-S][-SSS][P-SS][P-SS][P-SS][PPPP][-SSS]

Subtask/Task Score:

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

Score: 13

User: Bestzu

Problemset: ขนมปัง

Language: cpp

Time: 0.002 second

Submitted On: 2025-10-17 11:55:41

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;


void display(vector<int> &a) {
	for(auto &e : a) {
		cout << e << " ";
	}
	cout << endl;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);

	int w, h; cin >> w >> h;
	int m, n; cin >> m >> n;
	
	int w1 = 0, w2 = 0;
	vector<int> vertical;
	vector<int> horizontal;
	horizontal.push_back(0);
	vertical.push_back(0);
	//vertical
	for(int i = 0; i < m; i++) {
		int x; cin >> x;
		vertical.push_back(x);
	}
	vertical.push_back(w);
	//horizontal
	for(int i = 0; i < n; i++) {
		int x; cin >> x;
		horizontal.push_back(x);
	}
	horizontal.push_back(h);
	
	
	
	
//	display(vertical);
//	display(horizontal);
	
	//max width
	for(int i = vertical.size()-1; i > 0; i--) {
		int l = vertical[i] - vertical[i-1];
		if(l > w1) {
			w2 = w1;
			w1 = l;
		}
		else if(l > w2) {
			w2 = l;
		}
//		cout << "w1 = " << w1 << endl;
//		cout << "w2 = " << w2 << endl;
	}
	
	int h1 = 0, h2 = 0;
	//max height
	for(int i = horizontal.size()-1; i > 0; i--) {
		int h = horizontal[i] - horizontal[i-1];
		if(h > h1) {
			h2 = h1;
			h1 = h;
		}
		else if(h > h2) {
			h2 = h;
		}
//		cout << "h1 = " << h1 << endl;
//		cout << "h2 = " << h2 << endl;
	}
	cout << w1*h1 << " " << w2 * h1 << endl;
    return 0;
}