본문 바로가기

Algorithm

C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 10707번:수도요금 답

반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
using namespace std;
int main() {
    int a, b, c, d, p;
    int x, y;
    cin >> a >> b >> c >> d >> p;
    x = a * p;//x사의 수도요금
    if (c < p)//상한선을 넘을 경우
    {
        p -= c;
        y = b + d * p;
    }
    else
        y = b;
    int ans = x < y ? x : y;
    cout << ans << '\n';
}
cs