Saving Princess
来源:互联网 发布:车销 软件 编辑:程序博客网 时间:2024/06/11 10:07
Time Limit: 1 Second Memory Limit: 32768 KB Special Judge
Saving princesses is always a hard work. Ivan D'Ourack is planning to save the princess locked in the tower. However, n dangerous monsters are guarding the road from the city where Ivan lives to the tower where the princess is locked.
Fortunately Ivan is a warrior and a magician. Thus he can defeat monsters in a fight, and enchant them to pass unnoticed.
Initially Ivan has h health points, strength s, spell power p and m mana points. To defeat i-th monster in a fight, he must have strength at least si, and he loses max(2si - s, 0) health points in a fight. If the number of health points becomes 0 or less, Ivan dies. After defeating a monster Ivan's strength increases by 1.
To enchant i-th monster Ivan must have spell power at least pi and he spends mi mana points to do it. If Ivan does not have mi mana points, he cannot enchant the monster. After enchanting the monster Ivan's spell power increases by 1.
Find out, whether Ivan can save princess, and if he can how to do it.
Input
The first line of the input file contains n, h, s, p and m (1 ≤ n ≤ 50, 1 ≤ h ≤ 50, 0 ≤ s, p, m ≤ 50). The following n lines contain three integer numbers each --- si, pi, and mi (1 ≤ si, pi, mi ≤ 50).
There are multiple cases. Process to the end of file.
Output
If Ivan cannot save princess, output "UNLUCKY". In the other case output n characters, the i-th character must be 'D' if Ivan must defeat the i-the monster, or 'E' if he must enchant it.
Sample Input
3 12 5 5 65 5 26 5 26 7 33 11 5 5 65 5 26 5 26 7 3
Sample Output
DEDUNLUCKY
- Saving Princess
- ZOJ3369 Saving Princess,DP
- hdu4308 Saving Princess claire_
- hdu 4308 Saving Princess claire_
- HDU4308 Saving Princess claire_ BFS
- HDU 4308 Saving Princess claire_
- HDU-4038-Saving Princess Claire
- HDU 4308 - Saving Princess claire_
- hdu 4308 Saving Princess claire
- hdu 4308 Saving Princess claire
- HDU 4308 Saving Princess claire_
- HDU 4308 Saving Princess claire_
- UESTC 1811 Hero Saving Princess
- hdu 4308 - Saving Princess claire_
- HDU 4308 Saving Princess claire_
- HDU 4308 Saving Princess claire_
- hdu 4308 Saving Princess claire_
- HDU/HDOJ----4308 Saving Princess claire_
- N 个元素的数组,求第K大的元素
- MFC下 报表打印程序的实现
- Integer Numbers zoj 3365
- poj2780解题报告
- 今天让我们一起为舟曲灾区同胞祝福
- Saving Princess
- Python 插件杂谈 (3) ---- PyQuery , Python中的网页分析利器
- 开源3d游戏引擎的一些了解
- 幻镜 一
- 【SQL*Plus】使用BREAK和COMPUTE在SQL*Plus中得到分组统计结果
- MindMapper 总结SQL Server
- 开始学C+
- surfer画等值线
- 不使用鼠标浏览网页(firefox)