One of the upsides of using casualty ratios to assess CR and ELs rather than even trying to worry about this before is that you can always reach a fairly accurate assessment of the actual difficulty of an encounter.
An encounter of the group's level, if I recall correctly, is expected to expend about 25% of a party's resources.
Player characters and attached NPCs are resources.
The system is therefore simple: Consider the casualty ratio of the player party. If, for instance, the player party took 50% casualties in the encounter, then total would be equivalent to 2 encounters of the player party's level, because 50%, or 2*25%, of the party's resources were "expended".
As a benefit, this accounts for circumstantial modifiers which may have made the encounter more or less difficult. For example, monsters which attacked from ambush would inflict a higher casualty count, and therefore would have an enhanced challenge value.
Player ineptitude could also have increased the casualty counts, but even in this case, clearly, it was more of a learning experience. People obviously are able to learn more from an encounter that goes completely FUBAR than one which everything goes perfectly, meaning it was too easy.
In theory, players MIGHT attempt to deliberately be stupid to try to gain more experience, but in practice, their luck won't hold out that long, and they will shortly all die if they try and be stupid. Too bad.