結果

問題 No.684 Prefix Parenthesis
ユーザー %20%20
提出日時 2018-05-12 18:52:00
言語 Perl
(5.38.2)
結果
WA  
実行時間 -
コード長 363 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 5,324 KB
実行使用メモリ 23,128 KB
最終ジャッジ日時 2023-09-10 18:29:41
合計ジャッジ時間 3,478 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,720 KB
testcase_01 AC 2 ms
4,640 KB
testcase_02 AC 2 ms
4,736 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 105 ms
21,692 KB
testcase_17 AC 60 ms
14,148 KB
testcase_18 AC 4 ms
4,756 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 114 ms
23,004 KB
testcase_23 AC 112 ms
23,084 KB
testcase_24 AC 120 ms
23,128 KB
testcase_25 WA -
testcase_26 AC 3 ms
4,524 KB
testcase_27 AC 3 ms
4,728 KB
testcase_28 AC 3 ms
4,512 KB
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

$i=<>;
@(=@_=@)=0;
for(<>=~/./g){
	if(/\(/){
		$([@(]=$([-1]+1;
		$_[@_]=$_[-1];
		$)[@)]=$)[-1]
	}elsif($([-1]){
		$([@(]=$([-1]-1;
		$_[@_]=$_[-1]+1;
		$)[@)]=$)[-1]
	}else{
		$([@(]=$([-1];
		$_[@_]=$_[-1];
		$)[@)]=$)[-1]+1
	}
}
while($i){
	$a=$([$i]+$c;
	$b=$)[$i-1];
	if($a>$b){
		$c=$a-$b;
		$x+=$_[$i]+$b
	}else{
		$c=0;
		$x+=$_[$i]
	}
	--$i
}
print$x*2
0