The Actual Incomplete code in Python- def solve(k,h,knights,hillichurls): # compute and print answer here def main(): k, h = list(map(int,input().strip().split(" "))) knights = [] for i in range(k): name = input().strip() temp = list(map(int,input().strip().split(" "))) knights.append((name,temp)) hillichurls = [int(input().strip()) for i in range(h)] solve(k,h,knights,hillichurls) if __name__ == "__main__": main()
Need help in completing the code based on the information mentioned below in Python
Jean Gunnhildr, Acting Grand Master of the Knights of Favonius, intends to test the combat efficiency of the members of her organization. Despite the odd assortment of characters at her disposal she thinks they are capable fighters.
However, she would still like to perform a classical "DPS Check" as she gathers data in order to more efficiently assign missions to the Knights of Favonius.
To explain this, we will be using a simplified version of Genshin Impact's
Each character has an ATK stat. The character then has four attacks: a normal attack, charged attack, elemental skill, and elemental burst.
Each of these four attack types have a scaling factor. This determines how much damage is dealt relative to the attack. For example, if a character has 1523 ATK and their normal attack has 67% scaling, their normal attack would deal 1523 * 67% = 1523 * 0.67= 1020.41 damage. After this, damage is always rounded down. The final damage for the normal attack is 1020.
Jean has gathered a sizable amount of data involving hillichurls. For our purposes, we will abstract the consititution of these hillichurls using the concept of hit points. A hillichurl will have a fixed number of hit points. When a character attacks this hillichurl, their hit points are decreased by the damage dealt. When the hillichurl's hit points drop to 0 or lower, the hillichurl is defeated.
Given the number of hillchurls in the sample Jean collected, and the ATK stats and damage scaling of each of the moves of her Knights of Favonius, kindly print the ranking of all her knights in terms of most hillichurls defeated. You may assume that each character always uses their most effective move and the damage is applied exactly once to each of the hypothetical hillichurls in Jean's sample. See the sample input for an explanation of how this would look like.
Input Format
The first line contains two space-separated integers K and H indicating the number of knights and hillichurls to be considered in the problem.
2K lines follow, with every two lines describing one of Jean's Knights. The line will start with a single string indicating the knight's name. This string will only contain latin alphabet characters. All the names are guaranteed to be distinct. The next line contains five integers ATKi, NAi, CAi, ESi, EB indicating the ATK stat, normal attack scaling, charged attack scaling, elemental skill scaling, and elemental burst scaling of the ith character.
After all the knight description, H lines follow, each containing a single integer Hj, indicating the hit points of each of the H hillichurls in Jean's sample.
Constraints
1 ≤ K, H ≤ 10^5
1 ≤ ATKi ≤ 9 * 10^3
1 ≤ NAi, CAi, ESi, EBi ≤ 10^3
1≤ Hj ≤ 10^5 for all 1 ≤ i ≤ H
Output Format
Output K lines, each containing the name of the knight and an integer indicating the number of hillichurls they can defeat with their optimal attack separated by a single space. The knights must be sorted in non-ascending order according to the number of hillichurls defeated. In the case of a tie between two knights, print them in lexicographical order.
Sample Input 0
3 5 |
Sample Output 0
Fischl 2 Kaeya 2 Amber 1 |
Explanation 0
Amber's most powerful skill is her normal attack with 47% scaling. This deals 101 * 0.47= 47.47 = 47 damage, which can defeat 1 hillichurl, which is the second one.
Kaeya's most powerful skill is his elemental skill, with 49% scaling. This deals 473 * 0.49 = 231.77 = 231 damage, which can defeat the first 2 hillichurls.
Fischl's most powerful skill is her elemental skill, with scaling. This deals damage, which can defeat the first hillichurls.
In printing the rankings, Fischl and Kaeya both defeated 2 hillichurls, so they are printed in lexicographical order, with Fischl before Kaeya.
Sample Input 1
2 6 Timmie 9000 1000 100 500 100 Diluc 518 29 39 42 237 318 257 1490 3980 1960 3350 |
Sample Output 1
Timmie 6 Diluc 2 |
Explanation 1
Timmie's most powerful skill is his normal attack with 1000% scaling. This deals 9000 * 10.00 = 90000.00 = 90000 damage, which can defeat all 6 hillichurls.
Diluc's most powerful skill is his elemental burst, with 237% scaling. This deals 518 * 2.37 = 1227.66 = 1277 damage, which can defeat the first 2 hillichurls.
There are no ties, so Timmie is the top-ranked Knight of Favonius, followed by Diluc. #Timmie6Star
The Actual Incomplete code in Python-
def solve(k,h,knights,hillichurls): def main(): for i in range(k): hillichurls = [int(input().strip()) for i in range(h)] if __name__ == "__main__": |
Step by step
Solved in 3 steps with 2 images