BOJ/[ BOJ ] C++

[ C++ ] #1267 ( 휴대폰 요금 )

haena02 2022. 2. 9. 03:19
반응형

 

어려운 문제는 아니었는데...

계속 더 비싼 요금제를 추천하면서 "왜틀렸지!!" 하고있었다...ㅎㅎ

 

#include <iostream>
#include <algorithm>

using namespace std;

int main() {

	ios::sync_with_stdio(0);
	cin.tie(nullptr);

	int f;
	int a;
	cin >> f;
	int Y = 0;
	int M = 0;

	for (int i = 0; i < f; i++) {
		cin >> a;
		Y += ((a / 30) + 1)*10;
		M += ((a / 60) + 1) * 15;
	}

	
	if (Y < M) {
		cout << "Y " << Y;
	}else if (Y >M) {
		cout << "M " << M;
	}
	else {
		cout << "Y "<<"M " << M;
	}

}
반응형