forked from YashilDepani/Competitive-Programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinimum Product.cpp
More file actions
65 lines (56 loc) · 1.15 KB
/
Copy pathMinimum Product.cpp
File metadata and controls
65 lines (56 loc) · 1.15 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
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod (ll)1000000007
#define fast std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define input int t;cin>>t;while(t--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define f(i, a, b) for (int i = (a); i < (b); i++)
#define fr(i, a, b) for (int i = (a); i >= (b); i--)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define all(x) x.begin(), x.end()
#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define PI 3.1415926535897932384626433
int i,j,k;
int main()
{
input
{
cinll(a);
cinll(b);
cinll(x);
cinll(y);
cinll(n);
if(a>b)
{
swap(a,b);
swap(x,y);
}
ll np=n;
ll bp=b;
ll ap=a;
ll ans=1000000000000000000;
ll temp=min(n,b-y);
b=b-temp;
n=n-temp;
temp=min(n,a-x);
a=a-temp;
ans=min(ans,a*b);
b=bp;
a=ap;
n=np;
temp=min(n,a-x);
a=a-temp;
n=n-temp;
temp=min(n,b-y);
b=b-temp;
ans=min(ans,a*b);
cout<<ans<<"\n";
}
}