#### dcy931달 전

해당되는구역중에서 가장 큰 직사각형의 넓이에서 필요없는 직사각형의 넓이를 빼는식으로 문제를 해결했는데

어떤 케이스에서 틀리는지 찾기가 힘드네요 도와주세요

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int direction[6];
int size[6];

int check(int x,int y)
{
int tempplus = 0;
int tempminus = 0;
int i;

for ( i = 0; i < 6; i++)
{
if ( direction[i] == x )
tempplus += size[i];
else if ( direction[i] == y )
tempminus += size[i];
}
if ( tempplus > tempminus )
return tempminus;
else
return tempplus;
}

int main()
{
int fruit;
int i;
int maxx = -1,maxy = -1;
int minx = 1000,miny = 1000;
int result;
int x = 0, y = 0;
int tempplus,tempminus;

scanf("%d",&fruit);

for ( i = 0; i < 6; i++)
{
scanf("%d %d",&direction[i],&size[i]);

if ( direction[i] == 1 || direction[i] == 2 )
{
if ( size[i] > maxx )
maxx = size[i];
if ( size[i] < minx )
minx = size[i];

if ( direction[i] == 1 )
x += size[i];
else
x -= size[i];
}
else
{
if ( size[i] > maxy )
maxy = size[i];
if ( size[i] < miny )
miny = size[i];

if ( direction[i] == 3 )
y += size[i];
else
y -= size[i];
}
}

if ( x == 0 && y == 0)
result = ((maxx * maxy) - (minx * miny)) * fruit;
else
{
if ( x != 0 )
maxx = check(1,2);
if ( y != 0 )
maxy = check(3,4);

if ( x != 0 || y != 0)
{
if ( direction[0] == 1 ||  direction[0] == 2 )
{
if ( direction[0] == direction[2] &&  direction[1] == direction[3] )
result = ((maxx * maxy) - (size[2] * size[1])) * fruit;
else if ( direction[0] != direction[2] &&  direction[1] == direction[3] )
result = ((maxx * maxy) - (size[2] * size[3])) * fruit;
else if ( direction[0] == direction[2] &&  direction[1] != direction[3] )
result = ((maxx * maxy) - (size[0] * size[1])) * fruit;
else
result = ((maxx * maxy) - (size[4] * size[3])) * fruit;
}
else
{
if ( direction[0] == direction[2] &&  direction[1] == direction[3] )
result = ((maxx * maxy) - (size[1] * size[2])) * fruit;
else if ( direction[0] != direction[2] &&  direction[1] == direction[3] )
result = ((maxx * maxy) - (size[3] * size[2])) * fruit;
else if ( direction[0] == direction[2] &&  direction[1] != direction[3] )
result = ((maxx * maxy) - (size[1] * size[0])) * fruit;
else
result = ((maxx * maxy) - (size[3] * size[4])) * fruit;
}
}
}
printf("%d\n",result);
}

댓글을 작성하려면 로그인해야 합니다.