結果

問題 No.684 Prefix Parenthesis
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-01-28 11:56:58
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 164 bytes
コンパイル時間 120 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 25,088 KB
最終ジャッジ日時 2024-04-14 22:40:05
合計ジャッジ時間 11,734 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
12,160 KB
testcase_01 AC 88 ms
12,160 KB
testcase_02 AC 87 ms
12,160 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 AC 461 ms
24,064 KB
testcase_14 AC 449 ms
23,680 KB
testcase_15 AC 212 ms
15,872 KB
testcase_16 AC 449 ms
23,936 KB
testcase_17 AC 282 ms
18,432 KB
testcase_18 AC 94 ms
12,416 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 477 ms
24,832 KB
testcase_23 AC 466 ms
24,320 KB
testcase_24 AC 581 ms
24,704 KB
testcase_25 WA -
testcase_26 AC 89 ms
12,288 KB
testcase_27 AC 89 ms
12,288 KB
testcase_28 AC 90 ms
12,288 KB
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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