Problem E
Field Trip

You and your classmates are going on an exciting field trip to a downtown museum. Because the museum is an hour away, three buses of identical capacity and a van are dispatched as a means of transportation to the museum and back. The buses will first start loading only students, and once all students have been loaded then teachers will begin to fill in the remaining spots on the buses. Any remaining teachers will ride on the van. To make the bus ride more exciting, all the students are hoping for a “teacher free bus ride”! A teacher free bus ride is when none of the teachers are on a bus.
Students are grouped in
Given the sizes of each of the class sections, determine if
it is possible to load students onto
Input
The first line of input contains one integer
Output
If it is possible to load the students onto three identical
buses in the above-described fashion and have a teacher free
bus ride, then output two integers
If it is not possible, print “-1”.
Sample Input 1 | Sample Output 1 |
---|---|
3 3 3 3 |
1 2 |
Sample Input 2 | Sample Output 2 |
---|---|
3 9 10 11 |
-1 |
Sample Input 3 | Sample Output 3 |
---|---|
9 1 2 3 1 2 3 1 2 3 |
3 6 |
Sample Input 4 | Sample Output 4 |
---|---|
9 1 2 3 1 2 3 1 2 10 |
-1 |