-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path16937.cpp
45 lines (40 loc) · 974 Bytes
/
16937.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int H, W, N, ans = 0;
int map[101][101];
int R[101], C[101];
vector<pair<int, int>> v1;
bool roll(int r1, int r2, int c1, int c2) {
if (r1 + r2 <= H && max(c1, c2) <= W) return true;
if (max(r1, r2) <= H && c1 + c2 <= W) return true;
return false;
}
bool possible(int r1, int r2, int c1, int c2) {
if (roll(r1,r2,c1,c2)) return true;
if (roll(c1,r2,r1,c2)) return true;
if (roll(r1,c2,c1,r2)) return true;
if (roll(c1,c2,r1,r2)) return true;
return false;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> H >> W >> N;
for (int x = 0; x < N; x++) {
cin >> R[x] >> C[x];
}
for (int x = 0; x < N; x++) {
for (int y = x + 1; y < N; y++) {
int r1 = R[x], c1 = C[x];
int r2 = R[y], c2 = C[y];
if (possible(r1, r2, c1, c2)) {
ans = max(ans, r1*c1 + r2*c2);
}
}
}
cout<<ans;
return 0;
}