시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 154 | 78 | 69 | 54.762% |
Each of Farmer John's N (1 <= N <= 5,000) cows has a unique positive integer brand that fits nicely into 32 signed bits. He wishes the cows would line up in numerical order for feeding, but they never cooperate. To encourage good behavior, he allows a cow to eat only if it is the first cow to be chosen to eat or if its number is greater than the cow that ate before it.
Given a listing of the ordering of cow brands for the cows standing in line, what is the largest number of cows that can be fed using FJ rules?
Consider this line of 11 cows:
2 5 18 3 4 7 10 9 11 8 15
One could feed cows in the order 2, 3, 4, 7, 10 11, and 15 for a total of seven fed, the largest number possible.
One could not feed cows in the order 2, 5, 3, 10 15 since cow 3's brand is not greater than its predecessor, 5.
11 2 5 18 3 4 7 10 9 11 8 15
7