Result: Accepted
Time: 75ms
Memory: 1756kB
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdlib>
using namespace std;
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int a, b, c, d, e;
while(cin >> a >> b >> c >> d >> e){
int x = a - 2*e;
int y = b - 2*e;
int z = c - 2*e;
int l = a - 2*d;
int m = b - 2*d;
int n = c - 2*d;
if(d >= e){
if(d*2 >= a||d*2 >= b||d*2 >= c){
cout << a*b*c - x*y*z - 2*x*e*z - 2*y*e*z - 2*x*e*y << endl;
}else{
if(l*m*n > a*b*c - x*y*z - 2*x*e*z - 2*y*e*z - 2*x*e*y){
cout << l*m*n <<endl;
}else{
cout << a*b*c - x*y*z - 2*x*e*z - 2*y*e*z - 2*x*e*y << endl;
}
}
}else{
cout << a*b*c - 2*x*d*z - 2*y*d*z - 2*x*d*y <<endl;
}
}
return 0;
}