https://www.acmicpc.net/problem/14215
14215호: 3소절
첫 번째 행은 a, b, c(1 ≤ a, b, c ≤ 100)입니다.
www.acmicpc.net
Eclipse는 개발 환경으로 사용되었습니다.

암호
import java.util.Scanner;
public class Main {
public static void main(String() args) {
Scanner sc = new Scanner(System.in);
int a,b,c;
int max = -2;
int sum;
a = sc.nextInt();
if(a > max) {
max = a;
}
b = sc.nextInt();
if(max < b) {
max = b;
}
c = sc.nextInt();
if(max < c) {
max = c;
}
sum = a+b+c;
int t = sum - max;
if(max >= t) { // 삼각형이 되기 위한 조건을 만족해야 된다.
max = t - 1;
}
int ans = t + max; // 둘레의 길이 저장
System.out.println(ans);
sc.close();
}
}
삼각형이 되기 위한 조건을 생각하면 풀 수 있다.
삼각형이 되려면 가장 긴 변의 길이가 다른 두 변의 길이의 합보다 작아야 합니다.