結果

問題 No.684 Prefix Parenthesis
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-01-29 09:39:31
言語 Ruby
(3.2.2)
結果
AC  
実行時間 610 ms / 2,000 ms
コード長 163 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 11,428 KB
実行使用メモリ 27,504 KB
最終ジャッジ日時 2023-07-30 08:06:48
合計ジャッジ時間 12,868 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,276 KB
testcase_01 AC 82 ms
15,080 KB
testcase_02 AC 83 ms
15,080 KB
testcase_03 AC 209 ms
18,084 KB
testcase_04 AC 389 ms
22,932 KB
testcase_05 AC 453 ms
23,772 KB
testcase_06 AC 209 ms
17,996 KB
testcase_07 AC 404 ms
23,508 KB
testcase_08 AC 119 ms
15,784 KB
testcase_09 AC 124 ms
16,168 KB
testcase_10 AC 582 ms
26,772 KB
testcase_11 AC 351 ms
23,484 KB
testcase_12 AC 128 ms
16,436 KB
testcase_13 AC 478 ms
26,576 KB
testcase_14 AC 465 ms
26,076 KB
testcase_15 AC 212 ms
18,788 KB
testcase_16 AC 440 ms
26,248 KB
testcase_17 AC 267 ms
20,712 KB
testcase_18 AC 86 ms
15,264 KB
testcase_19 AC 496 ms
27,504 KB
testcase_20 AC 533 ms
27,408 KB
testcase_21 AC 573 ms
27,392 KB
testcase_22 AC 446 ms
26,748 KB
testcase_23 AC 450 ms
26,308 KB
testcase_24 AC 552 ms
26,968 KB
testcase_25 AC 610 ms
27,076 KB
testcase_26 AC 81 ms
15,008 KB
testcase_27 AC 84 ms
15,288 KB
testcase_28 AC 83 ms
15,256 KB
testcase_29 AC 496 ms
27,500 KB
testcase_30 AC 513 ms
27,496 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

a=b=0
l=[]
n=gets.to_i
gets.chomp.chars{|x|a-=x<')'?1:-1;b<a&&b=a;l<<[a,b]}
a=b=0
l.sort_by{|c,d|[e=c<=>0,e<0?d:c-d]}.map{|c,d|b<a+d&&b=a+d;a+=c}
p n*(n+1)/2+a-2*b
0