eunhak1221   2년 전

반례라도 있는 것일까요

#include
#include
using namespace std;

int main() {
int count = 0;
int sum1 = 0, sum2 = 0;
int a = 0;
int result = 0;

cin >> count;

int* arr = new int[count];
int* copy_1 = new int[count];
int* copy_2 = new int[count];

for (int i = 0; i < count; i++) {
cin >> arr[i];
}
for (int i = 0; i < count; i++) {
a = arr[i];
copy_1[i] = a;
copy_2[i] = a;
}

for (int i = 0; i < count; i++) {
while (copy_1[i] > 0) {
if ((copy_1[i] % 30) == 29) {
result = copy_1[i] / 30 + 1;
break;
}
else {
copy_1[i] = copy_1[i] - 29;
result++;
}
}
sum1 += result * 10;
result = 0;
}

for (int i = 0; i < count; i++) {
while (copy_2[i] > 0) {
if ((copy_2[i] % 60) == 59) {
result = copy_2[i] / 60 + 1;
break;
}
else {
copy_2[i] = copy_2[i] - 59;
result++;
}
}
sum2 += result * 15;
result = 0;
}

if (sum1 > sum2)
cout << "M" << " " << sum2;
else if (sum1 < sum2)
cout << "Y" << " " << sum1;
else
cout << "Y " << " " << "M" << " " << sum1;

}

lostid   2년 전

반례입니다.

<입력>

3

841 841 841

<출력>

Y 30

<정답>

M 675

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