結果

問題 No.22 括弧の対応
ユーザー history_Basshistory_Bass
提出日時 2017-03-03 01:37:27
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 750 bytes
コンパイル時間 3,231 ms
コンパイル使用メモリ 73,016 KB
実行使用メモリ 62,764 KB
最終ジャッジ日時 2023-09-03 21:33:57
合計ジャッジ時間 15,823 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class arc {
	public static void main(String args[]){
		
		//文字の読み込み
		Scanner sc=new Scanner(System.in);
		String line1=sc.nextLine();
		String line2=sc.nextLine();
		//文字の分割
		String[] ch1=line1.split(" ",0);//ch1[0]=the amount ch1[1]=question
		String[] ch2=line2.split("",0);//arcs
		
		int judge=0;
		int i;//=Integer.parseInt(ch1[1]);//この括弧のついの括弧の番号を求める
		int j=Integer.parseInt(ch1[0]);//括弧の総数
		for(i=Integer.parseInt(ch1[1])-1;i<j;i++){
	
			switch(ch2[i]){
				case "(": judge++;
				case ")": judge--;
			}
			
			if(judge==0){
				break;
			}
			
			if(i==(j-1)){
				i=0;
			}else{
				i++;
			}
		}

		System.out.println(i+1);
		
	}
}
0