Fair Photography
Time limit1sMemory limit128 MB
Cows at distinct positions are white or spotted, and after repainting some white cows you need the widest interval with equal counts.
- Level
Medium6 of 10
- Topics
- Prefix sum, Hash map, Sorting
- Solved
- No attempts yet
Problem
cows stand along a fence at distinct positions. Each is white (W) or spotted (S). You may paint some white cows spotted so an interval photo can have equal counts.
Photo size is max position minus min position among included cows. Find the maximum fair photo size.
Input
Line 1: .
Next lines: position and W or S.
Output
Maximum photo size.