topcoder-greed
topcoder-greed copied to clipboard
Always trim first when parsing params.
Sometimes even a simple string param may have redundant spaces like sample 2 in BagAndCards (SRM 679). Always trim first when parsing params will fix this.
The incorrect BagAndCards.sample
is given below. Note that there is a trailing space in sample 2.
I have debugged my solution for quite a while and found this bug in Greed during the contest...QQ
-- Example 0
2
4
1
1
0
0
NNYYNYN
9
-- Example 1
3
5
1
1
1
2
NNYYNYNYN
1532
-- Example 2
10
20
111
222
333
444
"NNNNNYYYNNNYYYYYYNNYYYYNNNNYNNYYYNNNYYN"
450750683
-- Example 3
2
2
1
1
0
0
NNY
1