#include <bits/stdc++.h>
using namespace std;
int main(){
int A, B, C, a, b, count[101]={0}, result=0;
cin >> A>> B >> C;
for(int i=0; i<3; i++){
cin >> a >> b;
for(int j=a; j<b; j++){
count[j]++;
}
}
for(int i=1; i<101; i++){
if(count[i]){
if(count[i]==1) result += count[i]*A;
else if (count[i] ==2) result += count[i]*B;
else if (count[i]==3 ) result += count[i]*C;
}
}
cout << result << "\n";
return 0;
}
쓰레기 값을 비워주지 않아서 한 번에 못풀었던 문제...
주차 시간 만큼 배열을 증가 시켜주고 해당 배열의 값을 기준으로 분기 처리해서 계산하도록 함
'스터디 > 알고리즘' 카테고리의 다른 글
[백준 10988] 팰린드롬인지 확인하기 (0) | 2022.05.11 |
---|---|
[백준 10808] 알파벳 개수 (0) | 2022.05.11 |
[알고리즘 강의] 이론편 (1) (0) | 2022.04.29 |
[백준 1343] 폴리오미노 (0) | 2022.03.17 |
[백준 10866] 덱 (0) | 2022.02.11 |