728x90
Code
int main(){
int price1;
int price2;
int price3;
int loop, loop2;
int arr[100] = { 0, };
int max = 0;
int i;
int result1 = 0;
int result2 = 0;
int result3 = 0;
scanf("%d %d %d", &price1, &price2, &price3);
if (1 <= price3&&price3 <= price2&&price2 <= price1&&price1 <= 100)
{
scanf("%d %d", &loop, &loop2);
if (!(1 <= loop&&loop <= 100 && 1 <= loop2&&loop2 <= 100)) return 0;
max = loop2;
for (loop; loop<loop2; loop++){
arr[loop - 1]++;
}
scanf("%d %d", &loop, &loop2);
if (!(1 <= loop&&loop <= 100 && 1 <= loop2&&loop2 <= 100)) return 0;
if (loop2 >= max){
max = loop2;
}
for (loop; loop<loop2; loop++){
arr[loop - 1]++;
}
scanf("%d %d", &loop, &loop2);
if (!(1 <= loop&&loop <= 100 && 1 <= loop2&&loop2 <= 100)) return 0;
if (loop2 >= max){
max = loop2;
}
for (loop; loop<loop2; loop++){
arr[loop - 1]++;
}
for (i = 0; i<max-1; i++){
if (arr[i] == 1)
{
result1 += price1 * arr[i];
}
else if (arr[i] == 2)
{
result2 += price2 * arr[i];
}
else if (arr[i] == 3)
{
result3 += price3 * arr[i];
}
}
}
printf("%d", result1 + result2 + result3);
return 0;
}
728x90
'Algorithm' 카테고리의 다른 글
정올/큐 (0) | 2019.02.06 |
---|---|
백준/2502/떡먹는호랑이 (0) | 2019.02.06 |
정올/소시지공장 (0) | 2019.02.06 |
정올/회의실배정 (0) | 2019.02.06 |
정올/실전대비/브라우저 (0) | 2019.02.06 |