编程介的小学生 2017-11-20 17:34 采纳率: 20.5%
浏览 887
已采纳

ZZY’s Dilemma

Problem Description
ZZY has many habits like seeing movie, listening music, playing PC game and football and so on. Besides he has many goals, as not every habit is good for achieving his goals, he falls into the dilemma of making a choice between his goals and habits.
Now ,we define the effect that one habit has on each goal is represented as a vector,and the elements of the vector are integers,ex.vector(100,90,-10,80)means it has 100 point effect on goal 1,90 point effect on goal 2,-10 point effect on goal 3 and 80 point effect on goal 4(the positive point means good effect and the negative point means bad effect),and the given requirement of each goal is represented as integer.please help ZZY to achieve his goals as well as keeps his habits as many as possible.

Input
There are multi cases , read the data until EOF.( No more than 10 cases )
Line 1: The number of ZZY’s goals N(0<N<=20)
Line 2: The requirement of each goals (0 < w <= 1000)
Line 3: The number of ZZY’s habits M(0 < M <= 16)
Line 4-M+4: Each line contains N integers, the ith integer represents the effect on ith goal (-1000 <= data <= 1000).

Output
For each case: The output is a single line that contains:

  • the maximum number of habits ZZY can keep, followed by:
  • a SORTED list (from smallest to largest) of the habit ZZY can keep. If more than one set of habits could meet the requirement, choose the set with the smallest habit numbers. Just please output 0 if there is no way to achieve ZZY’s goals.

Sample Input
4
100 200 300 400
3
100 100 400 500
100 -10 50 300
100 100 -50 -50

Sample Output
2 1 3

  • 写回答

1条回答 默认 最新

  • threenewbee 2018-09-01 15:23
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog