2851번 - 슈퍼 마리오
#define _CRT_SECURE_NO_WARNINGS
#include
int main(void)
{
int mushroom[11], score = 0;
for (int i = 1; i <= 10; i++)
scanf("%d", &mushroom[i]); // 입력
if (mushroom[1] == 100)
printf("%d", mushroom[1]);
else
score += mushroom[i];
if (score < 100)
if (score + mushroom[i + 1] >= 100)
int score1 = score + mushroom[i + 1];
int s1 = 100 - score;
int s2 = score1 - 100;
if (s1 > s2)
printf("%d", score1);
break;
}
else if (s1 == s2)
printf("%d", score);
continue;
return 0;
로직은 맞는 것 같은데 자꾸 틀렸다고 뜨네요. 테스트 케이스 넣어보았을 때에도 다 맞게 나옵니다.
반례가 있는지 확인해주시면 감사하겠습니다!!
댓글을 작성하려면 로그인해야 합니다.
jnaul990 2년 전
#define _CRT_SECURE_NO_WARNINGS
#include
int main(void)
{
int mushroom[11], score = 0;
for (int i = 1; i <= 10; i++)
scanf("%d", &mushroom[i]); // 입력
if (mushroom[1] == 100)
printf("%d", mushroom[1]);
else
{
for (int i = 1; i <= 10; i++)
{
score += mushroom[i];
if (score < 100)
{
if (score + mushroom[i + 1] >= 100)
{
int score1 = score + mushroom[i + 1];
int s1 = 100 - score;
int s2 = score1 - 100;
if (s1 > s2)
{
printf("%d", score1);
break;
}
else if (s1 == s2)
{
printf("%d", score1);
break;
}
else
{
printf("%d", score);
break;
}
}
else
continue;
}
}
}
return 0;
}
로직은 맞는 것 같은데 자꾸 틀렸다고 뜨네요. 테스트 케이스 넣어보았을 때에도 다 맞게 나옵니다.
반례가 있는지 확인해주시면 감사하겠습니다!!