Saleh127

CF 1409b

Sep 4th, 2020
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; while(t--)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. test
  11. {
  12.  
  13. ll a,c,x,y,n,i,j,k,l,d,e,ans=999999999999999999;
  14. cin>>a>>c>>x>>y>>n;
  15. i=a-x;
  16. j=c-y;
  17. if(i+j<=n)
  18. {
  19. l=(a-i)*(c-j);
  20. cout<<l<<endl;
  21. continue;
  22. }
  23. if(i<=n && (c-(n-i))>=y)
  24. {
  25. l=(a-i)*(c-(n-i));
  26. ans=min(ans,l);
  27. }
  28. if(j<=n && (a-(n-j))>=x)
  29. {
  30. l=(c-j)*(a-(n-j));
  31. ans=min(ans,l);
  32. }
  33. if(a-n>=x)
  34. {
  35. l=(a-n)*c;
  36. ans=min(ans,l);
  37. }
  38. if(c-n>=y)
  39. {
  40. l=(c-n)*a;
  41. ans=min(ans,l);
  42. }
  43. cout<<ans<<endl;
  44. }
  45.  
  46.  
  47. return 0;
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment