编程介的小学生 2017-04-22 16:26 采纳率: 20.5%
浏览 843
已采纳

Win the Bonus

There is a game with m bankers, each holding a string of integers of length 3 (note: an integer that has less than 3 digits has zeros filled to the left, e.g. 5 is considered as 005). Each banker assigns to his\her string some bonus or penalty points. As a player, you are supposed to select n digits from the set {0,1,2,3,4,5,6,7,8,9} to form your own integer string. If your string contains some of the bankers' strings, then you will gain or lose points accordingly. For example, if there are two bankers assigning 20 bonus points to 356 and 10 penalty points to 674 respectively, and your string is 035674, then since 356 and 674 both appear once in your string, the score you get will be 20-10=10. The player getting the most points wins the game. If there are more than one player getting the most points, the one with the smallest string number wins.
Now, suppose that Harry Potter gets to know all the bankers' secret strings and their assigned points by waving his magic wand, it is still not an easy task to win the game even with Hermione on his side. So he has come to you for help -- given the string length n, you may write a program to find the winning string.

Input
The input consists of several test cases.
The first line of each test case contains two integers m and n (1<=n<=10000), where m is the number of bankers and n is the required length of the player's string.
The following m lines contain m pairs of integers which are the banker's string and the points assigned to it.
You may assume that all the bankers' strings are distinct.

Output
For each test case you are supposed to output the winning string you find in a line. No extra spaces are allowed.

Sample Input:
2 5
356 20
674 -10

Sample Output:
00356

  • 写回答

1条回答 默认 最新

  • shen_wei 2017-04-27 07:30
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line