harbor run -t openthoughts/tasktrove-code-contests-noblock-code_contests-11860harbor download openthoughts/tasktrove-code-contests-noblock-code_contests-11860Problem description Tris (or as her parents call her Beatrice) is going through a series of training and evaluation to get into top 10 and remain in Dauntless Faction. She is currently placed 12th and will become faction-less if she fails, today. Four (or Tobias) gives Tris a string, consisting of 'i'(s) and 'd'(s) only. Tris has to select a number and increment it by 1 when she encounters 'i' and reduce it by 1 when she encounters 'd'. Thus calculate the final result. There are several results possible, but Four wants the starting number and the corresponding result, such that their sum is minimum. However there is a catch, like in all Dauntless exercises, the number cannot be negative at any step.
Input First line contains number of test cases.For each test case you have the string. given by Four to Tris
Output Help Tris by telling her the starting number and the corresponding result (In correct order), separated by a space. Print result for each test case in a new line.
Constraints SubTask 1 - 70 Points
1 ≤ T ≤ 100
1 ≤ length(string) ≤ 10^3
SubTask 2 - 30 Points
T =1
1 ≤ length(string) ≤ 100
Example Input: 1 iidiiii
Output: 0 5
Explanation 0 - 1(i) - 2(i) - 1(d) - 2(i) - 3(i) - 4(i) - 5(i) we start with 0 (zero) and add 1 for every 'i' and subtract 1 for every 'd' , checking at each step that value does not become negative
Solve this competitive programming problem.
Write a complete, self-contained Python solution to /app/solution.py.
Your solution must:
/app/solution.pyImportant: Your solution will be executed non-interactively as:
python3 /app/solution.py < input.txt
Do not use input() in a loop that waits for interactive input. Read all
input at once (e.g. import sys; data = sys.stdin.read()) and process it.
The solution will be validated against multiple test cases.