알고리즘/BOJ
[C++] 백준 1267번 핸드폰 요금
Jay, Lee
2021. 2. 28. 17:41
#include <iostream>
using namespace std;
int young(int arr[], int& calls) {
int result = 0;
for (int i = 0; i < calls; i++) {
int temp = (arr[i] / 30) + 1;
result += temp;
}
return result * 10;
}
int min(int arr[], int& calls) {
int result = 0;
for (int i = 0; i < calls; i++) {
int temp = (arr[i] / 60) + 1;
result += temp;
}
return result * 15;
}
int main() {
int calls;
cin >> calls;
int a[10000];
for (int i = 0; i < calls; i++) {
cin >> a[i];
}
int y = young(a, calls);
int m = min(a, calls);
if (y == m) {
cout << "Y M " << m << "\n";
}
else if (y > m) {
cout << "M " << m << "\n";
}
else {
cout << "Y " << y << "\n";
}
return 0;
}