으음... 어엄... 으음...
곱셈의 값이 작아지려면 둘 중 하나의 숫자가 작아져야 한다고 생각했다.
그래서 한쪽에 몰아서 n을 빼는 걸 두 번 확인하고 그 중 작은 값을 선택하면 된다고 생각했는데 틀렸다ㅠㅠㅠㅠ 뭐가 문제야
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <bitset>
#define xx first
#define yy second
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
using iii = tuple<int, int, int>;
void solve()
{
i64 a, b, x, y, n;
scanf("%lld %lld %lld %lld %lld", &a, &b, &x, &y, &n);
i64 res1 = 1, res2 = 1;
if (b - n >= y)
{
res1 = (b - n) * a;
}
else
{
res1 = y;
n -= b - y;
if (a - n >= x)
res1 *= (a - n);
else
res1 *= x;
}
if (a - n >= x)
{
res2 = (a - n) * b;
}
else
{
res2 = x;
n -= a - x;
if (b - n >= y)
res2 *= (b - n);
else
res2 *= y;
}
printf("%lld\n", min(res1, res2));
}
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
solve();
}
return 0;
}
아.. 알고보니 첫번째 비교하는 부분에서 값이 바뀌어서 그랬다.
그래서 함수로 따로 빼서 구했음.
맞았다 흑흑다흑흑...
'코드포스' 카테고리의 다른 글
[코드포스 Round 667] C. Yet Another Array Restoration (0) | 2020.11.12 |
---|---|
[코드포스 Round 667] A. Yet Another Two Integers Problem (0) | 2020.11.12 |
[코드포스 Round 667] 후기 (0) | 2020.11.12 |
[코드포스 Round 677] E. Two Round Dances (0) | 2020.11.07 |
[코드포스 Round 677] D. Districts Connection (0) | 2020.11.07 |