#include <stdio.h>
int main() {
int nowplan,nowplannum,useddata,bestplan,bestplannum,i;
int data[7]={300,1000,2000,6000,11000,0}, planfee[7]={29900,34900,39900,49900,59900,69900}, totalfee[7];
scanf("%d %d", &nowplan, &useddata);
for(i=0;i<6;i++){
if(useddata>data[i]){
if(useddata-data[i]>=5000){
if(totalfee[i]>=180000+planfee[i])
totalfee[i]=180000+planfee[i];
else
totalfee[i]=(useddata-data[i])*20 + planfee[i];
}
else{
if((useddata-data[i])>1250)
totalfee[i]=25000+planfee[i];
else
totalfee[i]=(useddata-data[i])*20 + planfee[i];
}
}
else{
totalfee[i]=planfee[i];
}
if(planfee[i]==nowplan)
nowplannum=i;
}
totalfee[5]=69900;
bestplan=29900; bestplannum=0;
for(i=1;i<6;i++){
if(totalfee[bestplannum]>totalfee[i]){
bestplannum=i;
bestplan=planfee[i];
}
}
printf("%d %d %d", bestplan, totalfee[nowplannum],totalfee[bestplannum]);
return 0;
}
nowplan : 현재 사용중인 요금제
nowplannum : 현재 사용중인 요금제 인덱스
useddata : 데이터 사용량(MB)
bestplan : 추천 요금제
bestplannum : 추천 요금제 인덱스
data[7] : 요금제별 데이터 제공량
planfee[7] : 요금제
totalfee[7] : 데이터 사용량에 따른 총 요금
인덱스 | 요금 | 데이터 |
0 | 29900 | 300 |
1 | 34900 | 1000 |
2 | 39900 | 2000 |
3 | 49900 | 6000 |
4 | 59900 | 11000 |
5 | 69900 | 0 |
처음 for문 알고리즘.
* 초과데이터 1,250이상? ⇔ 초과금 25,000원 이상?
'Goorm_C' 카테고리의 다른 글
[구름LEVEL][C] - 피자 쿠폰 (0) | 2022.01.11 |
---|---|
[구름LEVEL][C] - 재정 위기 (0) | 2022.01.08 |
[구름LEVEL][C] - 암스트롱 수(Narcissistic Number) (0) | 2022.01.08 |
[구름LEVEL][C] - 삼각형의 넓이 2 (0) | 2022.01.08 |
[구름LEVEL][C] - 3차원 배열 (0) | 2022.01.08 |