백준
백준 14215 - 세 막대(C++)
공대생의 잡다한 사전
2023. 12. 10. 00:06
문제 링크입니다. https://www.acmicpc.net/problem/14215
14215번: 세 막대
첫째 줄에 a, b, c (1 ≤ a, b, c ≤ 100)가 주어진다.
www.acmicpc.net

자세한 것은 코드를 참고해주세요.
#define _CRT_SECURE_NO_WARNINGS
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
#include <string>
using namespace std;
int x, y, z;
int maxi, sum;
int main() {
cin.tie(0);
cout.tie(0);
cin >> x >> y >> z;
sum = x + y + z;
maxi = max(x, y);
maxi = max(maxi, z);
if(maxi >= sum-maxi){
cout << (sum-maxi) + (sum-maxi-1);
}
else{
cout << sum;
}
return 0;
}

질문 및 조언은 댓글을 남겨주세요.