#P11308. Team Cohesion Possibility in Faction Assignment
Team Cohesion Possibility in Faction Assignment
Team Cohesion Possibility in Faction Assignment
There are n factions, each of which can have at most m members. Already, p people have been assigned to factions in such a way that no faction exceeds the limit. Now, a team of k people (called team \(\zeta\)) enters the room. Without changing the faction assignment of the already assigned p people, if it is possible for the entire team to join a single faction without exceeding the capacity, they will all join that faction; otherwise, the team will split up among different factions.
Your task is, given four integers \(n\), \(m\), \(k\), and \(p\), to determine the possibility of the team being able to join the same faction, regardless of the assignment of the already allocated \(p\) people (note that the assignment is arbitrary but valid, meaning no faction has more than \(m\) people). The answer should be one of the following:
- Always: In every possible valid assignment of the \(p\) people, there is at least one faction that can accommodate the team (i.e. a faction with at most \(m-k\) people).
- Never: In every valid assignment of the \(p\) people, no faction has enough space for the team (i.e. every faction has at least \(m-k+1\) people, making it impossible to add \(k\) more members); note that when \(p = n\cdot m\), all factions are full.
- Sometimes: Depending on the assignment, the team may or may not be able to join as a whole.
Hint: For a faction to be able to accept the team, its current number of members must be \(\leq m - k\). An adversary could try to block the team by assigning at least \(m-k+1\) people to every faction. This blocking is possible if \(p \geq n\cdot(m-k+1)\). Thus:
- If \(p < n\cdot(m-k+1)\), then no matter how the \(p\) people are assigned, at least one faction will have at most \(m-k\) people, and the team can always join together. (Output Always.)
- If \(p = n\cdot m\), then every faction is full, and the team can never join as a whole. (Output Never.)
- Otherwise, it is possible to block the team in some assignments but not in others. (Output Sometimes.)
inputFormat
The input consists of a single line containing four space-separated integers:
- n (number of factions)
- m (maximum capacity per faction)
- k (number of people in team \(\zeta\))
- p (number of people already assigned)
You can assume \(1 \leq k \leq m\) and \(p \leq n \cdot m\).
outputFormat
Output a single word: Always, Sometimes, or Never according to the possibility of the team joining the same faction as explained above.
sample
3 5 3 8
Always