반응형

이 문제는 영식이와 민식이의 요금제 계산 공식만 세워주면
간단히 해결할 수 있는 문제이다
통화시간을 x라고 하겠다
영식 요금제 : 10 + (x/30) * 10
민식 요금제 : 15 + (x/60) * 15
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int a,x;
int sum_y = 0, sum_m = 0;
cin >> a;
for (int tmp=0; tmp < a; tmp++)
{
cin >> x;
sum_y += 10 + (x/30) * 10;
sum_m += 15 + (x/60) * 15;
}
if (sum_y < sum_m) cout << "Y " << sum_y;
else if (sum_y > sum_m) cout << "M " << sum_m;
else cout << "Y M " << sum_y;
return 0;
}
반응형
'algorithm > 기초 코드' 카테고리의 다른 글
| [algorithm] 백준 15552번 빠른 A+B (0) | 2025.10.25 |
|---|---|
| [algorithm] 백준 10804 카드 역배치 (0) | 2025.10.18 |
| [algorithm] 백준 2309번 일곱난쟁이 (0) | 2025.10.18 |
| [algorithm] 백준 2587번 대표값2 (0) | 2025.10.18 |
| [algorithm] 백준 2576번 홀수 (0) | 2025.10.18 |
