-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1409B.cpp
More file actions
30 lines (28 loc) · 711 Bytes
/
1409B.cpp
File metadata and controls
30 lines (28 loc) · 711 Bytes
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
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
ll a, b, x, y, n;
cin >> a >> b >> x >> y >> n;
ll min;
ll first, sec;
ll temp = (a - x) >= n ? n : (a - x);
first = temp;
sec = (b - y) >= (n - temp) ? (n - temp) : (b - y);
min = (a - first) * (b - sec);
temp = (b - y) >= n ? n : (b - y);
first = temp;
sec = (a - x) >= (n - temp) ? (n - temp) : (a - x);
if ((b - first) * (a - sec) < min)
min = (b - first) * (a - sec);
cout << min << '\n';
}
return 0;
}