import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
String arr;
int i, j;
int wire = 0;
int cut = 0;
arr = scan.next();
int len = arr.length();
for (i = 0; i < len; i++) {
if (arr.charAt(i) == '(') {
wire++;
}
else if (arr.charAt(i) == ')' && arr.charAt(i - 1) == '(') {
wire--;
cut += wire;
}
else {
wire--;
cut++;
}
}
System.out.printf("%d", cut);
}
}
http://www.jungol.co.kr/bbs/board.php?bo_table=pbank&wr_id=2120&sca=2070
'정올문제소스코드' 카테고리의 다른 글
1161 : 하노이1 (0) | 2021.12.05 |
---|---|
1309 : 팩토리얼 (0) | 2021.12.05 |
1221 : 후위표기법1 (0) | 2021.12.05 |
1814 : 삽입정렬 횟수 세기 (0) | 2021.12.05 |
1157 : 버블정렬 (0) | 2021.12.05 |