Decisive Friday
InterviewTime limit1sMemory limit1024 MB
Given N job durations in days, decide whether some subset of them can be ordered so the work ends exactly on Friday, 4 days after Monday.
- Level
Medium4 of 10
- Topics
- Dynamic programming, Math
- Solved
- No attempts yet
Problem

Gomgomi made exercise his New Year goal this year too, but he has not once gone to the gym so far. To you, the one who keeps nagging him to work out, Gomgomi says he will go to the gym if there is a moment when he finishes his work exactly on Friday!
It is Monday now. You want to know whether you can rearrange the order of Gomgomi's jobs so that he can be sent to the gym.
Input
The first line contains the number of jobs . ()
The second line contains integers separated by spaces. ()
Output
On the first line, print YES if Gomgomi can be sent to the gym, and NO if he cannot.