結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
TatsuDX
|
| 提出日時 | 2016-09-08 23:29:23 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 151 ms / 5,000 ms |
| コード長 | 438 bytes |
| コンパイル時間 | 4,880 ms |
| コンパイル使用メモリ | 74,688 KB |
| 実行使用メモリ | 41,480 KB |
| 最終ジャッジ日時 | 2024-07-20 07:16:28 |
| 合計ジャッジ時間 | 6,961 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), k = sc.nextInt(), idx = 0;
int[] t = new int[n], st = new int[n];
String s = sc.next();
for(int i = 0; i < n; i++){
if(s.charAt(i) == '('){
st[idx] = i;
idx++;
} else {
idx--;
t[i] = st[idx];
t[st[idx]] = i;
}
}
System.out.println(t[k-1]+1);
}
}
TatsuDX