| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 413 | 121 | 97 | 28.869% |
Determine the farmer that wins the game if both farmers play optimally.
Each test case starts with a line containing $N,ドル followed by a line containing $a_1,\dots,a_N$.
It is guaranteed that the sum of all $N$ is at most 2ドル\cdot 10^5$.
5 1 4 1 9 2 2 3 2 7 10 3 4 9 4
Farmer Nhoj Farmer John Farmer John Farmer John Farmer Nhoj
For the first test case, Farmer John can remove 1ドル,ドル 2ドル,ドル or 3ドル$ cows from the first room. Whichever number he removes, Nhoj can remove the remaining cow(s), forcing FJ to lose when they circle back to the first room.
For the second test case, FJ can remove 5ドル$ cows, forcing Nhoj to work with only 4ドル$ cows remaining. Now, Nhoj can either remove 1ドル,ドル 2ドル,ドル or 3ドル$ cows. This is now similar to the first test case.
For the third and fourth test cases, FJ can immediately remove all the cows from the first room, forcing Nhoj to lose.
For the fifth test case, FJ can remove 1ドル,ドル 2ドル,ドル or 3ドル,ドル cows from the first room, and Nhoj can remove the rest right after. When they circle back around to the first room, FJ will lose.