Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- 스톡
- 오늘도코드잇
- 코테준비
- 노트북SSD교체
- JavaScript
- 기계식키보드
- 시간복잡도
- 몬스긱
- 긱바
- ADT
- Unity
- M1W
- 코테
- 추상적 자료형
- 코드잇TIL
- solved.ac
- 삼성노트북
- 백준
- 어도비
- 브론즈
- unityC#
- GMK67
- 자바스크립트
- 자료구조
- LinkedList
- 코드잇
- 코딩공부
- 노트북램교체
- 삼성노트북하판
- JS
Archives
- Today
- Total
SKYLIGHT STUDIO
[C++][1267] 핸드폰 요금 본문
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int call_num;
int Y_f, M_f = 0;
int calculate_Y(int a) {
return 10 * (a / 30 + 1);
}
int calculate_M(int b) {
return 15 * (b / 60 + 1);
}
int main()
{
cin >> call_num;
int* array = new int[call_num]();
for (int i = 0; i < call_num; i++) {
cin >> array[i];
M_f += calculate_M(array[i]);
Y_f += calculate_Y(array[i]);
}
if (Y_f < M_f) {
cout << "Y " << Y_f;
}
if (Y_f == M_f) {
cout << "Y M " << Y_f;
}
else {
cout << "M " << M_f;
}
delete[] array;
}
int* array = new int[];로 동적 배열을 선언해서 수행. 뒤에 ()를 붙이면 원소들이 0으로 초기화된다.
delete[] 잊지 말기
'Computer Programming > Coding Test(C++)' 카테고리의 다른 글
[C++/1076] 저항 (0) | 2024.10.08 |
---|---|
[C++][2547] 사탕 선생 고창영 (1) | 2024.10.02 |
[C++ 리바이브] C++ 동적 배열 (0) | 2024.10.02 |
[C++][1264] 모음의 개수 (0) | 2024.09.29 |
[C++ 리바이브] Stream, Cout, Cin (0) | 2024.09.26 |