编程介的小学生 2017-10-13 23:21 采纳率: 20.5%
浏览 1344
已采纳

Nikifor

Description

Nikifor has decided to present the dean of the Department of Mathematics and Mechanics with a linearly independent vector system (you know, that we've just celebrated jubilees of the University and of the Department). A store sells m items of n-dimensional vectors, m <= 2000, 3 <= n <= m. For each vector its price ci is known, 0 < i <= m. Nikifor wants to buy n linearly independent vectors paying for them minimal sum of money. Write a program that would determine which vectors Nikifor should buy or would inform that it is impossible to satisfy his requirements.
Input

The first line of an input contains numbers m and n separated with a space. The next m lines contain the vectors on sale. All of the coordinates are integers with an absolute value not exceeding 2 000. The numbers are separated from each other with a space. The next m lines contain prices ci, one number in each line. The prices are positive integers not exceeding 15 000.
Output

The first line of an output should contain the minimal amount of money that Nikifor is to pay or the number 0, if Nikifor's requirements cannot be satisfied in this store. If it is possible to make a purchase, then the next n lines should contain the numbers of the vectors that Nikifor should buy. If several sets of such numbers are possible, then you should write one of them which is minimal according to the lexicographic order.
Sample Input

5 3
1 0 0
0 1 0
0 0 1
0 0 2
0 0 3
10
20
30
10
10
Sample Output

40
1
2
4

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-10-31 00:35
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 iqoo11 如何下载安装工程模式
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?