404039: GYM101401 C Smiley Faces (C)
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
C. Smiley Faces (C)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
Mr. Light is not satisfied with the number of smiley faces in his string. Now he wants to mirror exactly one substring (one or more consecutive characters in the string) to increase the number of smiley faces as possible. Can you find the maximum number of smiley faces he can achieve?
InputThe input contains a non-empty string of no more than 2 × 105 characters. Each character is either ':', '(', or ')'.
OutputPrint the maximum number of smiley faces Mr. Light can achieve by mirroring exactly one substring.
ExamplesInput:(:):(:):)Output
4Input
:)::(:(:Output
3