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: Bestzu
Problemset: ขนมปัง
Language: cpp
Time: 0.002 second
Submitted On: 2025-10-17 12:01:10
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int main() {
ios::sync_with_stdio(false); cin.tie(0);
int w, h; cin >> w >> h;
int m, n; cin >> m >> n;
vector<int> vertical, horizontal;
vertical.push_back(0);
horizontal.push_back(0);
for(int i = 0; i < m; i++){
int x; cin >> x;
vertical.push_back(x);
}
vertical.push_back(w);
for(int i = 0; i < n; i++){
int x; cin >> x;
horizontal.push_back(x);
}
horizontal.push_back(h);
int w1=0, w2=0;
for(int i = 1; i < vertical.size(); i++){
int l = vertical[i] - vertical[i-1];
if(l > w1){ w2 = w1; w1 = l; }
else if(l > w2) w2 = l;
}
int h1=0, h2=0;
for(int i = 1; i < horizontal.size(); i++){
int hh = horizontal[i] - horizontal[i-1];
if(hh > h1){ h2 = h1; h1 = hh; }
else if(hh > h2) h2 = hh;
}
vector<int> ans = {w1*h1, w1*h2, w2*h1, w2*h2};
sort(ans.begin(), ans.end(), greater<int>());
cout << ans[0] << " " << ans[1] << endl;
return 0;
}