피너클의 it공부방
백준 1267 핸드폰 요금 (c++) : 피너클 본문
728x90
반응형
https://www.acmicpc.net/problem/1267
1267번: 핸드폰 요금
동호가 저번 달에 이용한 통화의 개수 N이 주어진다. N은 20보다 작거나 같은 자연수이다. 둘째 줄에 통화 시간 N개가 주어진다. 통화 시간은 10,000보다 작거나 같은 자연수이다.
www.acmicpc.net
간단한 구현문제다.
#include <iostream>
using namespace std;
int n;
int arr[21];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
int y = 0, m = 0;
for (int i = 0; i < n; i++) {
int a = arr[i];
while (a >= 0) {
a -= 30;
y += 10;
}
a = arr[i];
while (a >= 0) {
a -= 60;
m += 15;
}
}
if (y < m) cout << "Y " << y << endl;
else if (y > m) cout << "M " << m << endl;
else cout << "Y M " << y << endl;
}
전체코드다.
728x90
반응형
'백준' 카테고리의 다른 글
백준 2506 점수계산 (c++) : 피너클 (0) | 2022.07.01 |
---|---|
백준 1547 공 (c++) : 피너클 (0) | 2022.06.30 |
백준 19944 뉴비의 기준은 뭘까? (c++) : 피너클 (0) | 2022.06.25 |
백준 1389 케빈 베이컨의 6단게 법칙 (c++) : 피너클 (0) | 2022.06.23 |
백준 16928 뱀과 사다리 게임 (c++) : 피너클 (0) | 2022.06.22 |
Comments