-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path1409B.cpp
More file actions
68 lines (54 loc) · 1.16 KB
/
1409B.cpp
File metadata and controls
68 lines (54 loc) · 1.16 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#define DEBUG
#define MAXN 2000000000
#define ll long long int
#include <bits/stdc++.h>
using namespace std;
int main() {
#ifdef DEBUG
freopen("in.in", "r", stdin);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
ll a, b, x, y, l;
cin >> n;
while (n--) {
cin >> a >> b >> x >> y >> l;
// decrease a then b
ll _a = a, _b = b, _l = l;
if (_a-x <= _l) {
_l -= _a-x;
_a = x;
} else {
_a -= _l;
_l = 0;
}
if (_b - y <= _l) {
_l -= _b - y;
_b = y;
} else {
_b -= _l;
_l = 0;
}
ll ans1 = _a * _b;
// decrease b then a
_a = a; _b = b; _l = l;
if (_b - y <= _l) {
_l -= _b - y;
_b = y;
} else {
_b -= _l;
_l = 0;
}
if (_a-x <= _l) {
_l -= _a-x;
_a = x;
} else {
_a -= _l;
_l = 0;
}
ll ans2 = _a * _b;
cout << min(ans1, ans2) << endl;
}
return 0;
}