結果

問題 No.684 Prefix Parenthesis
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-01-28 12:01:00
言語 Ruby
(3.3.0)
結果
AC  
実行時間 629 ms / 2,000 ms
コード長 164 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 24,832 KB
最終ジャッジ日時 2024-04-14 22:51:30
合計ジャッジ時間 12,057 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
12,288 KB
testcase_01 AC 90 ms
12,288 KB
testcase_02 AC 89 ms
12,160 KB
testcase_03 AC 227 ms
15,360 KB
testcase_04 AC 410 ms
20,096 KB
testcase_05 AC 472 ms
20,864 KB
testcase_06 AC 222 ms
15,360 KB
testcase_07 AC 423 ms
20,608 KB
testcase_08 AC 127 ms
12,928 KB
testcase_09 AC 132 ms
13,312 KB
testcase_10 AC 610 ms
24,320 KB
testcase_11 AC 377 ms
20,480 KB
testcase_12 AC 141 ms
13,568 KB
testcase_13 AC 502 ms
24,192 KB
testcase_14 AC 482 ms
23,936 KB
testcase_15 AC 223 ms
15,744 KB
testcase_16 AC 460 ms
23,936 KB
testcase_17 AC 275 ms
17,920 KB
testcase_18 AC 95 ms
12,160 KB
testcase_19 AC 512 ms
24,832 KB
testcase_20 AC 548 ms
24,832 KB
testcase_21 AC 589 ms
24,832 KB
testcase_22 AC 466 ms
24,192 KB
testcase_23 AC 465 ms
23,936 KB
testcase_24 AC 573 ms
24,576 KB
testcase_25 AC 629 ms
24,832 KB
testcase_26 AC 88 ms
12,416 KB
testcase_27 AC 87 ms
12,160 KB
testcase_28 AC 87 ms
12,160 KB
testcase_29 AC 514 ms
24,832 KB
testcase_30 AC 534 ms
24,832 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]}.each{|c,d|b<a+d&&b=a+d;a+=c}
p n*(n+1)/2+a-2*b
0